1. 程式人生 > >[vue-router] missing param for named route "twitsUser": Expected "name" to match "[^/]+?", but received ""

[vue-router] missing param for named route "twitsUser": Expected "name" to match "[^/]+?", but received ""

分享圖片 outer route 直接 receive bsp r+ its mis

技術分享圖片

瀏覽器中出現這種效果的原因:

  是因為user這個變量直接寫在了name的後面

<router-link :to="{name:‘twitsUser‘,params:{name:user}}" class="headIcon"></router-link>//user 是變量

解決方案:

<router-link :to="{name:‘twitsUser‘,params:{name:‘+user+‘}}" class="headIcon"></router-link>

router.js中寫法:

{
        path:‘/twitsUser/:name‘
, name:‘twitsUser‘, component:TwitsUser, }

[vue-router] missing param for named route "twitsUser": Expected "name" to match "[^\/]+?", but received ""