0

代码没有问题,用chrome浏览器会报错,主要是出现在"push"的问题上。
是下面这一行代码出的问题:

this.$router.push(e);

chrome调试下报错如下:

用过weex-repair。会不会和这个有关?个人认为是vue-router并没有被应用。

<!-- router.js -->
import VueRouter from 'vue-router'
import Vue from 'vue'
import home  from './home.vue'
import me  from './me.vue'
Vue.use(VueRouter)
export default new VueRouter({
routes: [
  { path: '/home', component: home},
  { path: '/me', component: me}
 ]
})
<!-- entry.js -->
import foo from './src/foo.vue'
import router from './src/Router.js'
foo.el = '#root'
foo.router = router
export default new Vue(foo);
router.push('me')

1个回答

0

如果代码没有问题,那检查下package.json
比如是否配置正确

{
  "name": "WeexRouter",
  "description": "WeexRouter",
  "version": "0.1.0",
  "private": true,
  "main": "index.js",
  "keywords": [
    "weex",
    "vue"
  ],
  "scripts": {
    "build": "webpack",
    "dev": "webpack --watch",
    "serve": "node build/init.js && serve -p 8081",
    "debug": "weex-devtool"
  },
  "dependencies": {
    "vue": "^2.1.8",
    "vue-router": "^2.1.1",
    "vuex": "^2.1.1",
    "vuex-router-sync": "^4.0.1",
    "weex-vue-render": "^0.1.4"
  },
  "devDependencies": {
    "babel-core": "^6.20.0",
    "babel-loader": "^6.2.9",
    "babel-preset-es2015": "^6.18.0",
    "css-loader": "^0.26.1",
    "ip": "^1.1.4",
    "serve": "^1.4.0",
    "vue-loader": "^10.0.2",
    "vue-template-compiler": "^2.1.8",
    "webpack": "^1.14.0",
    "weex-devtool": "^0.2.64",
    "weex-loader": "^0.4.1",
    "weex-vue-loader": "^0.2.5"
  }
}

撰写答案

相似问题