Skip to content

Commit 7fb8262

Browse files
committed
fix all examples and e2e tests
1 parent 9624f31 commit 7fb8262

File tree

12 files changed

+49
-18
lines changed

12 files changed

+49
-18
lines changed

examples/counter-hot/Counter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { recentHistory } from './vuex/getters'
1818
export default {
1919
vuex: {
2020
actions,
21-
state: {
21+
getters: {
2222
count: state => state.count,
2323
recentHistory
2424
}

examples/counter-hot/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<title>vuex counter example</title>
66
</head>
77
<body>
8-
<counter></counter>
8+
<div id="app"></div>
99
<script src="build.js"></script>
1010
</body>
1111
</html>

examples/counter-hot/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import store from './vuex/store'
33
import Counter from './Counter.vue'
44

55
new Vue({
6-
el: 'body',
6+
el: '#app',
77
store,
8-
components: { Counter }
8+
render: h => h(Counter)
99
})

examples/shopping-cart/currency.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const digitsRE = /(\d{3})(?=\d)/g
2+
3+
export function currency (value, currency, decimals) {
4+
value = parseFloat(value)
5+
if (!isFinite(value) || (!value && value !== 0)) return ''
6+
currency = currency != null ? currency : '$'
7+
decimals = decimals != null ? decimals : 2
8+
var stringified = Math.abs(value).toFixed(decimals)
9+
var _int = decimals
10+
? stringified.slice(0, -1 - decimals)
11+
: stringified
12+
var i = _int.length % 3
13+
var head = i > 0
14+
? (_int.slice(0, i) + (_int.length > 3 ? ',' : ''))
15+
: ''
16+
var _float = decimals
17+
? stringified.slice(-1 - decimals)
18+
: ''
19+
var sign = value < 0 ? '-' : ''
20+
return sign + currency + head +
21+
_int.slice(i).replace(digitsRE, '$1,') +
22+
_float
23+
}

examples/shopping-cart/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<title>vuex shopping cart example</title>
66
</head>
77
<body>
8-
<app></app>
8+
<div id="app"></div>
99
<script src="build.js"></script>
1010
</body>
1111
</html>

examples/shopping-cart/main.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import 'babel-polyfill'
22
import Vue from 'vue'
33
import App from './components/App.vue'
44
import store from './vuex/store'
5+
import { currency } from './currency'
6+
7+
Vue.filter('currency', currency)
58

69
new Vue({
7-
el: 'body',
10+
el: '#app',
811
store,
9-
components: { App }
12+
render: h => h(App)
1013
})

examples/todomvc/components/App.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
<footer class="footer" v-show="todos.length">
2626
<span class="todo-count">
2727
<strong>{{ remaining }}</strong>
28-
{{ remaining | pluralize 'item' }} left
28+
{{ remaining | pluralize('item') }} left
2929
</span>
3030
<ul class="filters">
31-
<li v-for="(key, val) in filters">
32-
<a href="#/{{$key}}"
31+
<li v-for="(val, key) in filters">
32+
<a :href="'#/' + key"
3333
:class="{ selected: visibility === key }"
3434
@click="visibility = key">
3535
{{ key | capitalize }}
@@ -96,6 +96,10 @@ export default {
9696
}
9797
e.target.value = ''
9898
}
99+
},
100+
filters: {
101+
pluralize: (n, w) => n === 1 ? w : (w + 's'),
102+
capitalize: s => s.charAt(0).toUpperCase() + s.slice(1)
99103
}
100104
}
101105
</script>

examples/todomvc/components/Todo.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ export default {
4040
}
4141
},
4242
directives: {
43-
focus (value) {
43+
focus (el, { value }, { context }) {
4444
if (value) {
45-
this.vm.$nextTick(() => {
46-
this.el.focus()
45+
context.$nextTick(() => {
46+
el.focus()
4747
})
4848
}
4949
}

examples/todomvc/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<title>vuex todomvc example</title>
66
</head>
77
<body>
8-
<app></app>
8+
<div id="app"></div>
99
<script src="build.js"></script>
1010
</body>
1111
</html>

examples/todomvc/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import App from './components/App.vue'
44

55
new Vue({
66
store, // inject store to all children
7-
el: 'body',
8-
components: { App }
7+
el: '#app',
8+
render: h => h(App)
99
})

0 commit comments

Comments
 (0)