我自定义了一个组件,在.wxml中添加了hidden="{{modalHidden}}",在对应的js中添加了
Component({
properties: {
modalHidden: {//这里定义了modalHidden属性,属性值可以在组件使用时指定.写法为modal-hidden
type: Boolean,
value: true
},
},
data: {
text: "text",
},
methods: {
// 跳转
startAnswerButton() {
wx.navigateTo({
url: "XXX"
});
},
//取消
closeReward() {
this.setData({
modalHidden: true,
})
}
}
});
然后在调用的.wxml中加入
<modal modal-hidden="{{is_modal_hidden}}" modal-msg="{{is_modal_Msg}}" />
但是无论是true 还是 false 都会显示
<modal modal-hidden="{{isModalHidden}}" modal-msg="{{isModalMsg}}" />
在 properties 定义段中,属性名采用驼峰写法(propertyName);在 wxml 中,指定属性值时则对应使用连字符写法(component-tag-name property-name="attr value"),应用于数据绑定时采用驼峰写法(attr="{{propertyName}}")。