在学习路由时,想给
贴个代码:
index.html
命名视图 <router-link v-on:click="myClick" to="/home">首页About
main2.js
var router=[
{
path:'/',
redirect:'/home'
},
{
name:'home',
path:'/home',
component:{
template:
Home
}
},
{
name:'about',
path:'/about',
component:{
template:
about
}
},
]
var route=new VueRouter({
routes:router,
})
new Vue({
el:'#app',
router:route,
methods:{
myClick:function(){
console.log(this.$router.options.routes)
}
},
data:{
}
})
文章:
https://segmentfault.com/q/1010000007896386
在 click后面加native即可生效
vue 自己定义的标签
添加之后点击时间生效:
Original: https://www.cnblogs.com/crazy-lc/p/15173226.html
Author: MyBeans
Title: Vue router-link点击事件不生效
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/714387/
转载文章受原作者版权保护。转载请注明原作者出处!