From 0e4b5a0f2f00edf143079beac18c038088987a9f Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Mon, 6 Jul 2020 15:22:33 +0800 Subject: [PATCH] feat: add emits option --- src-next/button/index.js | 2 ++ src-next/cell/demo/index.vue | 8 +++++++- src-next/cell/index.js | 2 ++ src-next/col/index.js | 2 ++ src-next/image/index.js | 2 ++ src-next/mixins/popup/index.js | 7 +++---- src-next/popup/index.js | 2 ++ src-next/row/index.js | 2 ++ src-next/tag/index.js | 2 ++ 9 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src-next/button/index.js b/src-next/button/index.js index 689b9aaa1..b6f10f751 100644 --- a/src-next/button/index.js +++ b/src-next/button/index.js @@ -44,6 +44,8 @@ export default createComponent({ }, }, + emits: ['click', 'touchstart'], + methods: { onClick() { if (!this.loading && !this.disabled) { diff --git a/src-next/cell/demo/index.vue b/src-next/cell/demo/index.vue index f7b47398a..d8b0d46ac 100644 --- a/src-next/cell/demo/index.vue +++ b/src-next/cell/demo/index.vue @@ -2,7 +2,7 @@ - + @@ -108,6 +108,12 @@ export default { verticalCenter: 'Vertical center', }, }, + + methods: { + onClick() { + console.log('click'); + }, + }, }; diff --git a/src-next/cell/index.js b/src-next/cell/index.js index 83703384a..8a7afee58 100644 --- a/src-next/cell/index.js +++ b/src-next/cell/index.js @@ -14,6 +14,8 @@ export default createComponent({ ...routeProps, }, + emits: ['click'], + setup(props, { slots, emit }) { return function () { const { icon, size, title, label, value, isLink } = props; diff --git a/src-next/col/index.js b/src-next/col/index.js index 99f0c3e23..36db2b39c 100644 --- a/src-next/col/index.js +++ b/src-next/col/index.js @@ -15,6 +15,8 @@ export default createComponent({ }, }, + emits: ['click'], + computed: { style() { const { index } = this; diff --git a/src-next/image/index.js b/src-next/image/index.js index 9519f4a01..008793a38 100644 --- a/src-next/image/index.js +++ b/src-next/image/index.js @@ -31,6 +31,8 @@ export default createComponent({ }, }, + emits: ['load', 'error', 'click'], + data() { return { loading: true, diff --git a/src-next/mixins/popup/index.js b/src-next/mixins/popup/index.js index b626fbbe8..9a18f9ee4 100644 --- a/src-next/mixins/popup/index.js +++ b/src-next/mixins/popup/index.js @@ -39,13 +39,12 @@ export const popupMixinProps = { export function PopupMixin(options = {}) { return { - mixins: [ - TouchMixin, - CloseOnPopstateMixin, - ], + mixins: [TouchMixin, CloseOnPopstateMixin], props: popupMixinProps, + emits: ['open', 'close', 'update:show', 'click-overlay'], + data() { return { inited: this.show, diff --git a/src-next/popup/index.js b/src-next/popup/index.js index df2dfe120..cb28f8d5e 100644 --- a/src-next/popup/index.js +++ b/src-next/popup/index.js @@ -39,6 +39,8 @@ export default createComponent({ }, }, + emits: ['click', 'opened', 'closed'], + beforeCreate() { const createEmitter = (eventName) => (event) => this.$emit(eventName, event); diff --git a/src-next/row/index.js b/src-next/row/index.js index 9500641c6..b111023df 100644 --- a/src-next/row/index.js +++ b/src-next/row/index.js @@ -20,6 +20,8 @@ export default createComponent({ }, }, + emits: ['click'], + computed: { spaces() { const gutter = Number(this.gutter); diff --git a/src-next/tag/index.js b/src-next/tag/index.js index 8b3543438..3ddd51ee9 100644 --- a/src-next/tag/index.js +++ b/src-next/tag/index.js @@ -22,6 +22,8 @@ export default createComponent({ }, }, + emits: ['close'], + setup(props, { slots, emit }) { return function () { const { type, mark, plain, color, round, size } = props;