omip - fix event
This commit is contained in:
parent
ff8f1c9ff6
commit
5e2a96afbb
|
@ -2,7 +2,6 @@
|
|||
import { WeElement, define } from 'omi'
|
||||
import '../my-element'
|
||||
|
||||
//兼容 omi 下划线?
|
||||
import './index.css'
|
||||
|
||||
define('my-counter', class extends WeElement {
|
||||
|
@ -16,11 +15,13 @@ define('my-counter', class extends WeElement {
|
|||
|
||||
sub = () => {
|
||||
this.data.count--
|
||||
this.fire('change', this.data.count)
|
||||
this.update()
|
||||
}
|
||||
|
||||
add = () => {
|
||||
this.data.count++
|
||||
this.fire('change', this.data.count)
|
||||
this.update()
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,10 @@ class Component {
|
|||
}
|
||||
|
||||
install() { }
|
||||
|
||||
fire(type, data) {
|
||||
this._weappRef.triggerEvent(type, data)
|
||||
}
|
||||
}
|
||||
|
||||
const WeElement = Component
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import util from '../../utils/util'
|
||||
import { WeElement, define } from 'omi'
|
||||
import '../../components/my-counter'
|
||||
//兼容 omi 下划线?
|
||||
|
||||
import './index.css'
|
||||
|
||||
define('page-logs', class extends WeElement {
|
||||
|
@ -15,12 +15,16 @@ define('page-logs', class extends WeElement {
|
|||
})
|
||||
|
||||
this.update()
|
||||
|
||||
}
|
||||
|
||||
counterChange = (evt)=> {
|
||||
console.log(evt.detail)
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<view>
|
||||
<my-counter></my-counter>
|
||||
<my-counter onChange={this.counterChange}></my-counter>
|
||||
<view class="container log-list">
|
||||
{this.data.logs.map((log, index) => (
|
||||
<text class="log-item">{index + 1}. {log}</text>
|
||||
|
|
Loading…
Reference in New Issue