vue 利用hash值实现刷新无跳转页面
生活随笔
收集整理的這篇文章主要介紹了
vue 利用hash值实现刷新无跳转页面
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
//子組件一定要有name值
<template><div><ul><li @click="aaa(i)" v-for="(v, i) in nav" :key="i">{{ v }}</li><components :is="active"></components></ul></div>
</template><script>
import One from './One'
import Two from './Two'
import Three from './Three'
export default {mounted() {let str = window.location.hashthis.active = str.replace('#', '')},data() {return {nav: ['one', 'two', 'three'],list: [One.name, Two.name, Three.name],active: 'One',}},components: {One,Two,Three,},methods: {aaa(i) {this.active = this.list[i]window.location.hash = this.list[i]},},
}
</script>
?
總結
以上是生活随笔為你收集整理的vue 利用hash值实现刷新无跳转页面的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 五月份有什么水果?六月份又是什么呢?
- 下一篇: input失去焦点验证格式_vue2多文