下载
npm i vue-navigation --save
main.js
import Navigation from 'vue-navigation';
Vue.use(Navigation, {router}); // vue-router 实例
app.vue
<template>
<div id="app">
<navigation>
<router-view></router-view>
</navigation>
</div>
</template>
页面跳转时报如下错误 在main.js 加入下方代码
image.png
import Router from 'vue-router'
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)
}
router 中必须要有name 才会生效
export default new Router({
routes: [
{
path: "/index",
name: "index",
component: () => import("@/views/home/index")
},
网友评论