Closed Dreampie closed 9 years ago
请给重现,光看这样的代码完全没法帮你。
https://github.com/Dreampie/vue-demo 完整的demo在这儿 可以本地run起来
唉,我解释一下吧。完整的 demo 看起来很花时间,而且你的问题太笼统,有可能是你自己用法有问题,我没有那么多时间来帮你看。你得自己先花时间把问题范围缩小到一个合适的程度,如果是 bug 重现,就只重现 bug 就行了。
代码很少的,就是一个routes两个view,src/app.coffee是入口,src/routes.coffee是路由 ,src/view里是两个视图,要是给你重现的话,怎么给你重现?
to.path ,from.path from.path 没有变化
before : /hotwords,/ 6all.js:83
before : /a,/ all.js:83
before : /hotwords,/ all.js:83
before : /a,/
//app.coffee
Vue = require 'vue'
VueRouter = require 'vue-router'
Vue.use VueRouter
router = new VueRouter history: true
console.log require './routes'
#define routes
router.map require './routes'
#VueResource = require 'vue-resource'
#Vue.use VueResource
# global before
# you can perform async rejection here
router.beforeEach (to, from, allow, deny)->
console.log "before : " + to.path + "," + from.path
# global after
router.afterEach (to, from)->
console.log "after : " + to.path + "," + from.path
App = Vue.extend
components:
'app-header': require './component/header'
'app-sidebar': require './component/sidebar'
data: ->
'menus': [
{'name': '热词', 'icon': 'glyphicon glyphicon-header', 'url': '/hotwords'},
{'name': '热词', 'icon': 'glyphicon glyphicon-header', 'url': '/a'}
]
'tabs': []
events:
'init-view': (data)->
this.$set 'tabs', data.tabs
router.start App, '#app'
//routes.coffee
'use strict'
module.exports =
'/hotwords':
component: require './view/hotword'
'*':
component: require './view/notfound'
点击v-link 链接,router-view 没有更新