關於路由跳轉小方法
阿新 • • 發佈:2018-12-03
html:
<div>
<ul>
<li v-for="(item,index) in routeList" :key="index" :class="{ select: selItem==index}" @click="routeSelect(index)">
{{item}}
</li>
</ul>
</div>
js:
data(){ selItem:0, routeList: [ '首頁', 'get', 'post', 'other', 'ask', 'content' 'note' ], pathList: [ '/', '/main/get', '/main/post', '/main/other', '/main/ask', '/main/content', '/main/note', ], }, routeSelect(index) { this.selItem = index; this.$router.push({ path: this.pathList[index] }); },