JavaScript/vue.js/刷新页面
来自康健生活
< JavaScript | vue.js
无需重新加载页面或刷新dom
history.pushState
addHashToLocation(params) {
history.pushState(
{},
null,
this.$route.path + '#' + encodeURIComponent(params)
)
}
addHashToLocation('/my/new/path')
// main component
created() {
// event fire when pushState
this.$nuxt.$on('pushState', params => {
// do your logic with params
})
},
beforeDestroy() {
this.$nuxt.$off('pushState')
},
...
// Where there are history.pushState
this.$nuxt.$emit('pushState', params)
history.replaceState
No categories