嗨,對不起,我的菜鳥問題。我需要路由器鏈接的系結引數值。我搜索了很多,我認為我的代碼是正確的,但不起作用。
<router-link :to="{name: 'registro-new', params: {id: cliente.id}}">registro </router-link>
這是 console.log 中的錯誤
[Vue warn]: Unhandled error during execution of setup function
at <RouterLink to=
Object { name: "registro-new", params: {…} }
?
name: "registro-new"
?
params: Object { id: undefined }
?
<prototype>: Object { … }
>
at <Cliente onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > >
at <RouterView>
at <Dashboard onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > >
at <RouterView key="/cliente/1" >
at <App> runtime-core.esm-bundler.js:6873:16
我認為 cliente.id 為空,但如果我{{cliente.id}}在里面寫到div 我得到值。
如果我手動輸入這樣的數字我的路線作業
<router-link :to="{name: 'registro-new', params: {id:1}}">registro </router-link>
所以我真的不知道我的壞在哪里。有人能幫助我嗎?
uj5u.com熱心網友回復:
看起來在渲染時客戶端 id 尚未可用,因此添加一個條件以在 id 準備好時渲染路由器鏈接v-if="cliente.id":
<router-link v-if="cliente.id" :to="{name: 'registro-new', params: {id: cliente.id}}">
registro
</router-link>
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/395506.html
