我正在尝试将SPA从作为将组件加载到组件的路由页面的模态更改为SPA。我可以使用html中的to="/fixtures"
打开一个页面,但不能传递带有prop并带有一些数据的组件。如何使用vue-router和bootstrap-vue fixtures
传递<b-nav tabs> <b-nav-item>
的道具?
Home.vue不起作用:
<b-nav-item to="/fixtures" :fixtures="fixtures">Fixtures</b-nav-item>
来自路由器的index.js:
import Vue from "vue";
import VueRouter from "vue-router";
import Home from "@/components/Home.vue";
import Scorers from "@/components/Scorers.vue"
import LeagueTable from "@/components/LeagueTable";
import Fixtures from "@/components/Fixtures";
Vue.use(VueRouter);
export default new VueRouter({
routes: [
{
path: "/",
name: "Home",
component: Home
},
{
path: "/fixtures",
name: "Fixtures",
component: Fixtures,
props: true
}
],
mode: "history"
});
使用模态,此方法有效:
<b-tab title="Fixtures">
<Fixtures :fixtures="fixtures" />
</b-tab>
最佳答案
要将道具作为路线的一部分传递,请使用以下命令:
<b-nav-item :to="{ path: '/fixtures', props: { fixtures: fixtures } }">Fixtures</b-nav-item>