扫码关注官方订阅号
点击每个卡片就可以看到了错误信息了
{{currentCardInfo.values[1].value}}
光阴似箭催人老,日月如移越少年。
请把代码贴全撒
props里面驼峰写法的属性在html里面需要转换成-分割的属性,所以edit-panel的currentCardInfo修改如下
-
<edit-panel ... :current-card-info="cardInfo" ... > </edit-panel>
{{currentCardInfo.values && currentCardInfo.values[1].value}}
子组件中使用
props:{ currentCardInfo:Object }
来获取父组件传递的属性值
由于你{{currentCardInfo.values[1].value}}中,currentCardInfo.values未定义,所以对于未定义的currentCardInfo.values,currentCardInfo.values[1]无法获取到,所以报这个错误,解决方法是:在访问currentCardInfo.values[1]数据之前先判断一下currentCardInfo.values是否存在:
currentCardInfo.values
currentCardInfo.values[1]
如果currentCardInfo.values不存在,那么,后面的currentCardInfo.values[1].value就不会被运行到。
currentCardInfo.values[1].value
但是,我建议你把父组件中调用子组件的代码贴出来,方便进一步给出修改意见。
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
请把代码贴全撒
props里面驼峰写法的属性在html里面需要转换成
-分割的属性,所以edit-panel的currentCardInfo修改如下
子组件中使用
来获取父组件传递的属性值
由于你
{{currentCardInfo.values[1].value}}中,currentCardInfo.values未定义,所以对于未定义的currentCardInfo.values,currentCardInfo.values[1]无法获取到,所以报这个错误,解决方法是:在访问currentCardInfo.values[1]数据之前先判断一下currentCardInfo.values是否存在:如果
currentCardInfo.values不存在,那么,后面的currentCardInfo.values[1].value就不会被运行到。但是,我建议你把父组件中调用子组件的代码贴出来,方便进一步给出修改意见。