소스 검색

fix all examples and e2e tests

Evan You 9 년 전
부모
커밋
7fb8262a8c

+ 1 - 1
examples/counter-hot/Counter.vue

@@ -18,7 +18,7 @@ import { recentHistory } from './vuex/getters'
 export default {
   vuex: {
     actions,
-    state: {
+    getters: {
       count: state => state.count,
       recentHistory
     }

+ 1 - 1
examples/counter-hot/index.html

@@ -5,7 +5,7 @@
     <title>vuex counter example</title>
   </head>
   <body>
-    <counter></counter>
+    <div id="app"></div>
     <script src="build.js"></script>
   </body>
 </html>

+ 2 - 2
examples/counter-hot/main.js

@@ -3,7 +3,7 @@ import store from './vuex/store'
 import Counter from './Counter.vue'
 
 new Vue({
-  el: 'body',
+  el: '#app',
   store,
-  components: { Counter }
+  render: h => h(Counter)
 })

+ 23 - 0
examples/shopping-cart/currency.js

@@ -0,0 +1,23 @@
+const digitsRE = /(\d{3})(?=\d)/g
+
+export function currency (value, currency, decimals) {
+  value = parseFloat(value)
+  if (!isFinite(value) || (!value && value !== 0)) return ''
+  currency = currency != null ? currency : '$'
+  decimals = decimals != null ? decimals : 2
+  var stringified = Math.abs(value).toFixed(decimals)
+  var _int = decimals
+    ? stringified.slice(0, -1 - decimals)
+    : stringified
+  var i = _int.length % 3
+  var head = i > 0
+    ? (_int.slice(0, i) + (_int.length > 3 ? ',' : ''))
+    : ''
+  var _float = decimals
+    ? stringified.slice(-1 - decimals)
+    : ''
+  var sign = value < 0 ? '-' : ''
+  return sign + currency + head +
+    _int.slice(i).replace(digitsRE, '$1,') +
+    _float
+}

+ 1 - 1
examples/shopping-cart/index.html

@@ -5,7 +5,7 @@
     <title>vuex shopping cart example</title>
   </head>
   <body>
-    <app></app>
+    <div id="app"></div>
     <script src="build.js"></script>
   </body>
 </html>

+ 5 - 2
examples/shopping-cart/main.js

@@ -2,9 +2,12 @@ import 'babel-polyfill'
 import Vue from 'vue'
 import App from './components/App.vue'
 import store from './vuex/store'
+import { currency } from './currency'
+
+Vue.filter('currency', currency)
 
 new Vue({
-  el: 'body',
+  el: '#app',
   store,
-  components: { App }
+  render: h => h(App)
 })

+ 7 - 3
examples/todomvc/components/App.vue

@@ -25,11 +25,11 @@
     <footer class="footer" v-show="todos.length">
       <span class="todo-count">
         <strong>{{ remaining }}</strong>
-        {{ remaining | pluralize 'item' }} left
+        {{ remaining | pluralize('item') }} left
       </span>
       <ul class="filters">
-        <li v-for="(key, val) in filters">
-          <a href="#/{{$key}}"
+        <li v-for="(val, key) in filters">
+          <a :href="'#/' + key"
             :class="{ selected: visibility === key }"
             @click="visibility = key">
             {{ key | capitalize }}
@@ -96,6 +96,10 @@ export default {
       }
       e.target.value = ''
     }
+  },
+  filters: {
+    pluralize: (n, w) => n === 1 ? w : (w + 's'),
+    capitalize: s => s.charAt(0).toUpperCase() + s.slice(1)
   }
 }
 </script>

+ 3 - 3
examples/todomvc/components/Todo.vue

@@ -40,10 +40,10 @@ export default {
     }
   },
   directives: {
-    focus (value) {
+    focus (el, { value }, { context }) {
       if (value) {
-        this.vm.$nextTick(() => {
-          this.el.focus()
+        context.$nextTick(() => {
+          el.focus()
         })
       }
     }

+ 1 - 1
examples/todomvc/index.html

@@ -5,7 +5,7 @@
     <title>vuex todomvc example</title>
   </head>
   <body>
-    <app></app>
+    <div id="app"></div>
     <script src="build.js"></script>
   </body>
 </html>

+ 2 - 2
examples/todomvc/main.js

@@ -4,6 +4,6 @@ import App from './components/App.vue'
 
 new Vue({
   store, // inject store to all children
-  el: 'body',
-  components: { App }
+  el: '#app',
+  render: h => h(App)
 })

+ 1 - 1
examples/todomvc/vuex/store.js

@@ -24,7 +24,7 @@ const mutations = {
   },
 
   DELETE_TODO (state, todo) {
-    state.todos.$remove(todo)
+    state.todos.splice(state.todos.indexOf(todo), 1)
   },
 
   TOGGLE_TODO (state, todo) {

+ 2 - 1
package.json

@@ -49,6 +49,7 @@
     "eslint-config-vue": "^1.0.0",
     "function-bind": "^1.1.0",
     "mocha": "^2.3.4",
+    "phantomjs-prebuilt": "^2.1.7",
     "rollup": "^0.32.0",
     "rollup-plugin-babel": "^2.4.0",
     "sinon": "^1.17.3",
@@ -56,7 +57,7 @@
     "todomvc-app-css": "^2.0.3",
     "uglify-js": "^2.6.2",
     "vue": "^2.0.0-alpha.5",
-    "vue-loader": "^9.0.1",
+    "vue-loader": "^9.0.3",
     "webpack": "^1.12.8",
     "webpack-dev-server": "^1.12.1"
   }