xhml 文件
<text>pages/assembly/assembly.wxml</text>
<view wx:for="{{i_data}}">
<londng goodsItem="{{item}}"></londng>
</view>
json 文件
{
"usingComponents": {
"londng": "/compontes/londng"
}
}
自定义组件文件
组件的 xtml 文件
<text bindtap='tap_gtx'>{{item.title}}</text>
// compontes/londng.js
Component({
/**
* 组件的属性列表
*/
properties: {
goodsItem:{
type: 'object',
value: {},
observer: '_itemChange'//接收参数
}
},
/**
* 组件的初始数据
*/
data: {
item:{}
},
/**
* 组件的方法列表
*/
methods: {
_itemChange(val){
const that=this;
that.setData({
item:val
})
console.log(val);
},
tap_gtx(){
wx.showToast({
title: '哪哈',
icon:'none'
})
}
}
})