omi-mp - add triggerEvent to mp
This commit is contained in:
parent
7effed93ff
commit
195ea0a051
|
@ -10,7 +10,7 @@
|
|||
|
||||
# 快速体验
|
||||
|
||||
把小程序项目拷贝到 src-mp 目录,然后执行:
|
||||
把小程序项目拷贝到 src-mp 目录,如果是新的小程序,可以在 src-mp 目录创建小程序,然后执行:
|
||||
|
||||
```bash
|
||||
npm start //开发
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<!--components/my-child/my-child.wxml-->
|
||||
<text>my-child</text>
|
||||
<text>I am child component</text>
|
||||
|
|
|
@ -19,7 +19,7 @@ Component({
|
|||
*/
|
||||
methods: {
|
||||
myMethods: function() {
|
||||
console.log('myMethods')
|
||||
this.triggerEvent('myevent', { name: 'dntzhang' })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -11,5 +11,9 @@ Page({
|
|||
return util.formatTime(new Date(log))
|
||||
})
|
||||
})
|
||||
},
|
||||
myEventHandler: function (evt) {
|
||||
//output -> dntzhang
|
||||
console.log(evt.detail.name)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue