コンポーネントから $route.params.post にデータを渡そうとしていますが、どこかで失敗しており、それを機能させる方法がわかりません。
私のコンポーネントrouter-link
では、ルートファイルの特定のパスに移動するために使用していますが、指定されたコンポーネントにルーティングしていません。
// Component.vue
<router-link :to="{ path: 'replies', params: { post: postId }}">
<div class="button is-light is-small has-replies" @click=" postId = thread.no ">Replies</div>
//clicking replies will push the thread number to data and load it into the params
</router-link>
export default {
data () {
return {
postId: null
}
}
}
// ./routes/index.js
import Replies from '../components/Replies'
routes: [
{ path: '/', component: Frontpage },
{ path: '/replies/:post', component: Replies }
]
ボタンをクリックすると、次のようなルートで Replies コンポーネントが開きますが/replies/#
、空白のページが読み込まれ、コンポーネントが完全に無視されるだけです。にインポートvuex-router-sync
していますが、それが問題かどうかはわかりませんが、正しくmain.js
使用しているかどうか完全に確信が持てないため、問題がある可能性があることは十分承知しています。vuex-router-sync