vuejs - 点击页面,刷新当前页面的时候, 要使用watch,否则当前页面不会自动刷新
访问量: 2951
参考: https://router.vuejs.org/guide/advanced/data-fetching.html#fetching-after-navigation 和 https://github.com/vuejs/vue-router/issues/1012
如题。要使用watch
export default { data () { return { .... } }, mounted() { this.fetchData() }, methods: { truncate: truncate, fetchData: function () { Vue.http.get(url).then((response ) => { }, (response) => { console.error(response) }) }, go: function (vid){ this.$router.push({name: 'ShowVideo', params: { vid: vid}}) } }, watch: { "$route": 'fetchData' // 要watch route , 一旦发生变化,就调用 fetchData方法 } }