vue+vue-cli开发一些常见问题集合

1. Cannot read property 'target' of undefined

解决:给事件添加参数'$event' ,

@blur=' checkName( $event)'

2.多页面跳转问题:

平常我们都习惯用vue+vueRouter开发单页面应用,突然要做多页面还有点不习惯。

我的建议是,不管你几个页面,App.vue保持相对“干净”,尽量不要去改,把页面都写到components文件夹下,我们可以把整个页面也当做App.vue的一个组件。然后在router里注册路径后,给跳转事件添加

this. $router. push({ path: "/manage" });

这个就好了,注意要在router/index.js下注册一下path:"/manage",这就是你要跳转的页面

3.多级路由、子路由:直接看代码吧

{
path: "/manage",
component: Manage,
children: [{
path: '/',
component: ParameterSetting
}]
}


猜你喜欢

转载自blog.csdn.net/illusion_melody/article/details/80949182