【微信小程序】组件Component常用案例

今天用了,总结一下。

Component组件可以在页面上使用,如

<comp1 isshow='{{p_isshow}}' bindcancel='cancel'></comp1>

 

comp1.js里

Component({
    //对外属性
    properties:{
       ishow{
            type:Boolean,
            value:true,
            observer:function(){}} //属性变化时的监控器
    },
    //对内属性,跟页面没什么区别
    data:{
        
    }
    //方法
    methods:{
        showMoney:function(){}
    }
  //周期函数
})

 

页面:

data{
    p_isshow:true
}
cancel:function()
{
    var that =this;
    that.setData({p_isshow:false})
}

 

posted on 2020-04-25 17:28  一个小目标一次坑记录  阅读(636)  评论(0编辑  收藏  举报