------json:
{
"usingComponents": {}
}
----页面
Component({
properties: {
like: {
type:Boolean,
value:false
},
count:{
type:Number,
value:0
},
demo:{
type:String,
value:‘string‘
}
},
data:{
yseSrc:‘/images/component/like-1.png‘,
noSrc: ‘/images/component/like.png‘
//需要开发出来的数据,封装在内部开发出来,从外部可以设置,我们称之为属性
// like false
// count 0
},
methods: {
onLike: function () {
let like= this.data.like
let count= this.data.count
count=like?count-1:count+1
this.setData({
count:count,
like:!like
})
}
}
})
------xml
<view bind:tap="onLike">
<image src="{{like?yseSrc:noSrc}}"></image>
<view>like:{{like}}</view>
<view>count:{{count}}</view>
</view>