diff --git a/packages/omip/my-app/src/components/my-counter/index.js b/packages/omip/my-app/src/components/my-counter/index.js index 4e2b786ed..4e114cc80 100644 --- a/packages/omip/my-app/src/components/my-counter/index.js +++ b/packages/omip/my-app/src/components/my-counter/index.js @@ -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() } diff --git a/packages/omip/my-app/src/libs/omip/index.js b/packages/omip/my-app/src/libs/omip/index.js index 5321207fb..77e92db2f 100644 --- a/packages/omip/my-app/src/libs/omip/index.js +++ b/packages/omip/my-app/src/libs/omip/index.js @@ -10,6 +10,10 @@ class Component { } install() { } + + fire(type, data) { + this._weappRef.triggerEvent(type, data) + } } const WeElement = Component diff --git a/packages/omip/my-app/src/pages/logs/index.js b/packages/omip/my-app/src/pages/logs/index.js index 51a67c6d8..ee3c5767f 100644 --- a/packages/omip/my-app/src/pages/logs/index.js +++ b/packages/omip/my-app/src/pages/logs/index.js @@ -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 ( - + {this.data.logs.map((log, index) => ( {index + 1}. {log}