【发布时间】:2020-04-07 21:29:25
【问题描述】:
我是 Vuejs 新手,所以很抱歉这是一个新手问题。
我已向我的应用程序添加了一个路由器,我想将我的主应用程序中的数据渲染到我的组件模板中,但它不起作用。
这就是我所拥有的:
Vue.use(VueRouter);
const Text = { props: ['text'], template: '<div>This is the text: {{text}} </div>' }
const routes = [
{ path: '*', component: Text, props: true }
]
const router = new VueRouter({
routes: routes
})
new Vue({
router: router,
el: "#app",
data: {
text: "Hello there!"
}
})
我预计 text 道具将链接到我的 App.data.text,但它没有发生。
这是一个 jsfiddle:https://jsfiddle.net/fguillen/psqztn93
【问题讨论】:
标签: javascript vue.js vue-router vue-props