vue属性不是传递给儿童组件的
我无法使它起作用似乎很荒谬,但是当将道具传递给子部门时,道具的价值永远不会改变,而disablefootertext
始终是错误的。我做错了吗?
父母:
<MyChildComponent :disableFooterText="true">
孩子:
<MyCustomDropdown :footerText="footerText">
props: {
disableFooterText: {
default: false,
type: Boolean
},
}
computed: {
footerText() {
if (this.disableFooterText) { // always false
return '';
}
return 'Lorem impsum'; // always returns this value
},
}
It seems ridiculous that I can't get this to work, but when passing a prop to a child component, the value of the prop never actually changes and disableFooterText
is always false. Am I doing something wrong?
Parent:
<MyChildComponent :disableFooterText="true">
Child:
<MyCustomDropdown :footerText="footerText">
props: {
disableFooterText: {
default: false,
type: Boolean
},
}
computed: {
footerText() {
if (this.disableFooterText) { // always false
return '';
}
return 'Lorem impsum'; // always returns this value
},
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用
kebab-case
prop:Try with
kebab-case
prop:尝试kebab case @nikola pavicevic要求您做,或尝试
v-bind =“ {disableFooterText:true}”
。Try kebab case as @Nikola Pavicevic asked you to do, or try a
v-bind="{ disableFooterText: true }"
.