vuejs / vue-router

🚦 The official router for Vue 2
http://v3.router.vuejs.org/
MIT License
18.99k stars 5.06k forks source link

v-link could not update view. #54

Closed Dreampie closed 9 years ago

Dreampie commented 9 years ago
menus: [
      {'name': '热词', 'icon': 'glyphicon glyphicon-header', 'url': '/hotwords'},
      {'name': '热词', 'icon': 'glyphicon glyphicon-header', 'url': '/a'}
    ]

<ul>
    <li v-repeat="menus">
      <a v-link="{{url}}">
        <i class="{{icon}}" aria-hidden="true"></i>
        <span>{{name}}</span>
      </a>
    </li>
  </ul>

module.exports =
  '/hotwords':
    component: require './view/hotword'
  '*':
    component: require './view/notfound'

<router-view id="view" class="view" v-transition="view" transition-mode="out-in"></router-view>

点击v-link 链接,router-view 没有更新

yyx990803 commented 9 years ago

请给重现,光看这样的代码完全没法帮你。

Dreampie commented 9 years ago

https://github.com/Dreampie/vue-demo 完整的demo在这儿 可以本地run起来

yyx990803 commented 9 years ago

唉,我解释一下吧。完整的 demo 看起来很花时间,而且你的问题太笼统,有可能是你自己用法有问题,我没有那么多时间来帮你看。你得自己先花时间把问题范围缩小到一个合适的程度,如果是 bug 重现,就只重现 bug 就行了。

Dreampie commented 9 years ago

代码很少的,就是一个routes两个view,src/app.coffee是入口,src/routes.coffee是路由 ,src/view里是两个视图,要是给你重现的话,怎么给你重现?

Dreampie commented 9 years ago

to.path ,from.path from.path 没有变化

before : /hotwords,/   6all.js:83 
before : /a,/  all.js:83 
before : /hotwords,/   all.js:83 
before : /a,/
Dreampie commented 9 years ago
//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'

image image