[英]passing value from parent to child not working
Using Vuu.js, I'm trying to pass a value from parent to child component.使用 Vuu.js,我试图将值从父组件传递到子组件。 I have this working fine with a provided example.
通过提供的示例,我可以正常工作。 But when I change the name, it stops working.
但是当我更改名称时,它停止工作。 I can't figure out what i'm doing wrong.
我无法弄清楚我做错了什么。 My understanding on props is limited, i'm still trying to get me head around it.
我对道具的理解有限,我仍在努力解决它。
Working Example:工作示例:
https://codepen.io/sdras/pen/788a6a21e95589098af070c321214b78 https://codepen.io/sdras/pen/788a6a21e95589098af070c321214b78
HTML HTML
<div id="app">
<child :text="message"></child>
</div>
JS JS
Vue.component('child', {
props: ['text'],
template: `<div>{{ text }}</div>`
});
new Vue({
el: "#app",
data() {
return {
message: 'hello mr. magoo'
}
}
});
Non Working Example:非工作示例:
HTML HTML
<div id="app">
<child :myVarName="message"></child>
</div>
JS JS
Vue.component('child', {
props: ['myVarName'],
template: `<div>{{ myVarName }}</div>`
});
new Vue({
el: "#app",
data() {
return {
message: 'hello mr. magoo'
}
}
});
保留更新示例中的所有内容,除了在HTML中将“myVarName”更改为“my-var-name” - 这是默认情况下由 Vue 完成的,在 js 中,您仍然可以使用驼峰式版本 myVarName。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.