omi-mp - add triggerEvent to mp

This commit is contained in:
dntzhang 2018-11-10 07:37:58 +08:00
parent 7effed93ff
commit 195ea0a051
6 changed files with 10 additions and 6 deletions

View File

@ -10,7 +10,7 @@
# 快速体验
把小程序项目拷贝到 src-mp 目录,然后执行:
把小程序项目拷贝到 src-mp 目录,如果是新的小程序,可以在 src-mp 目录创建小程序,然后执行:
```bash
npm start //开发

View File

@ -1,2 +1,2 @@
<!--components/my-child/my-child.wxml-->
<text>my-child</text>
<text>I am child component</text>

View File

@ -19,7 +19,7 @@ Component({
*/
methods: {
myMethods: function() {
console.log('myMethods')
this.triggerEvent('myevent', { name: 'dntzhang' })
}
}
})

View File

@ -1,4 +1,4 @@
<view>
<my-child />
<view bindtap="myMethods">my-ele</view>
<button bindtap="myMethods">Click me will log dntzhang to the console panel</button>
<my-child />
</view>

View File

@ -11,5 +11,9 @@ Page({
return util.formatTime(new Date(log))
})
})
},
myEventHandler: function (evt) {
//output -> dntzhang
console.log(evt.detail.name)
}
})

View File

@ -3,5 +3,5 @@
<block wx:for="{{logs}}" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log}}</text>
</block>
<my-ele />
<my-ele bindmyevent="myEventHandler" />
</view>