File tree Expand file tree Collapse file tree 12 files changed +49
-18
lines changed
Expand file tree Collapse file tree 12 files changed +49
-18
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import { recentHistory } from './vuex/getters'
1818export default {
1919 vuex: {
2020 actions,
21- state : {
21+ getters : {
2222 count : state => state .count ,
2323 recentHistory
2424 }
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import store from './vuex/store'
33import Counter from './Counter.vue'
44
55new Vue ( {
6- el : 'body ' ,
6+ el : '#app ' ,
77 store,
8- components : { Counter }
8+ render : h => h ( Counter )
99} )
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change @@ -2,9 +2,12 @@ import 'babel-polyfill'
22import Vue from 'vue'
33import App from './components/App.vue'
44import store from './vuex/store'
5+ import { currency } from './currency'
6+
7+ Vue . filter ( 'currency' , currency )
58
69new Vue ( {
7- el : 'body ' ,
10+ el : '#app ' ,
811 store,
9- components : { App }
12+ render : h => h ( App )
1013} )
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change @@ -4,6 +4,6 @@ import App from './components/App.vue'
44
55new Vue ( {
66 store, // inject store to all children
7- el : 'body ' ,
8- components : { App }
7+ el : '#app ' ,
8+ render : h => h ( App )
99} )
You can’t perform that action at this time.
0 commit comments