微信小程序向组件传参布尔无效

时间:2025-04-17 09:06:44

<com-list listType="1" pageId="{{pageId}}" content_item2="content-item" content_item-left="content-left" wrapper2="wrapper_2" showTitles="false"></com-list>

 

错误原因

showTitles在没有{{}}的情况下,会将传入的值解析为字符串

{{}}才能将传入的值解析为表达式或数据层的属性或布尔值

正确写法

<com-list listType="1" pageId="{{pageId}}" content_item2="content-item" content_item-left="content-left" wrapper2="wrapper_2" showTitles="{{false}}"></com-list>