猿问

vue路由报错:TypeError: Cannot read property 'matched'

使用vue路由

js文件如下


import Vue from 'vue'

import VueRouter from 'vue-router'

import Daohangafter from './vue/daohangafter.vue'

new Vue({

    el:'#five',

    template:'<div><h1>数据获取</h1><hr/><Daohangafter></Daohangafter></div>',

    components:{

        Daohangafter

    }

})

vue文件如下


<template>

<div>

<h2>导航完成后过去数据</h2>

<div>

<router-link to="/shuju/one">/shuju/one</router-link>

<router-link to="/shuju/two">/shuju/two</router-link>

<router-link to="/shuju/three">/shuju/three</router-link>

</div>

<div v-if="loading">Loading...</div>

<router-view>

</router-view>

</div>

</template>

<script>

import Vue from 'vue'

import VueRouter from 'vue-router'

Vue.use(VueRouter)

const Pagepages={

    template:'<div>fkafnbkfapdp</div>'

}

const router=new VueRouter({

    mode:'history',

    base:__dirname,

    routes:[

       {

       path:'/shuju/:id',

        name:'shuju',

        component:Pagepages

   }

    ]

})


export default{

    name:'daohangafter',

    data(){

    return{

      loading:false,

      post:null

    }

    }

}

</script>

在浏览器查看效果发现报错

请问是为什么报错,哪里出现问题呢?如何改正呢?

小怪兽爱吃肉
浏览 976回答 1
1回答

慕容森

&nbsp; export default {&nbsp; &nbsp; name: 'daohangafter',&nbsp; &nbsp; data() {&nbsp; &nbsp; &nbsp; return {&nbsp; &nbsp; &nbsp; &nbsp; loading: false,&nbsp; &nbsp; &nbsp; &nbsp; post: null&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; },&nbsp; &nbsp; router&nbsp; }
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答