1 2 3 4 |
this.triggerEvent('getList', { page, size }) |
Example
example.json
1 2 3 4 5 6 7 |
{ "usingComponents": { "pageView": "../../components/page-view/index", "item-view": "./item-view", // <-- USE THIS as our generic component "body": "../../components/body-view/index" } } |
Notice here we have declared the generic:itemview to take on our item-view component here. item-view was imported in our .json file.
example.wxml
1 2 3 4 |
<body alignItem="center"> <pageView class="page-view" bind:getList="getUserList" list="{{userList}}" total="{{userTotal}}" generic:itemview="item-view"> </pageView> </body> |
example.wxss
1 2 3 |
.page-view{ width: inherit; } |
Item View
item-view.js
1 2 3 4 5 6 7 8 9 10 11 12 |
Component({ properties: { item: Object, key: Object }, data: {}, attached() { console.log('item', item); console.log('key', key); }, methods: {} }) |
item-view.json
1 2 3 4 5 6 7 |
{ "component": true, "usingComponents": { "mp-icon": "weui-miniprogram/icon/icon", "recorder": "../../components/recorder/recorder" } } |
item-view.wxml
1 2 3 4 5 6 7 8 9 10 11 12 |
<view class="voice-item itemViewBckgndColor" > <!-- only the the initial item view has an image--> <view class="_logo-box" wx:if="{{key==0}}"> <image class="logo" src="{{ item.image }}" mode="aspectFill" /> </view> <!-- required --> <view class="_title-box">{{ item.title }}</view> <recorder></recorder> </view> |
item-view.wxss
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
.voice-item{ display: flex; flex-direction: column; align-items: center; background: #313132; border-style:solid; border-width:1px; padding: 1rem 2rem 1rem 2rem; } ._logo-box { background: rgba(255,255,255, 0.1); padding: .8rem; margin: 1rem 0; border-radius: .5rem; width: 15rem; height: 15rem; } ._logo-box image { width: 100%; height: 100%; border-radius: .5rem; } ._title-box { width: 100%; color: #fbfbfd; margin-bottom: 2rem; } .itemViewBckgndColor { background-color: red; } |