diff --git a/src/components/confirm/metas.yml b/src/components/confirm/metas.yml index 7bc4806d3..588298882 100755 --- a/src/components/confirm/metas.yml +++ b/src/components/confirm/metas.yml @@ -38,6 +38,8 @@ extra: | onCancel () {} onConfirm () {} }) + // 设置输入值 + this.$vux.confirm.setInputValue('value') // 注意需要在 onShow 事件中执行 ``` props: show: @@ -123,6 +125,11 @@ methods: en: set input value when show-input is true zh-CN: 设置输入值,当 show-input 为 true 时有效 changes: + next: + en: + - '[feature] Support method:setInputValue for plugin #1846' + zh-CN: + - '[feature] 插件支持 setInputValue 方法 #1846' v2.5.7: en: - '[feature] Support prop:input-attrs #1799' diff --git a/src/demos/Confirm.vue b/src/demos/Confirm.vue index f63cd86df..17321f11c 100755 --- a/src/demos/Confirm.vue +++ b/src/demos/Confirm.vue @@ -184,10 +184,12 @@ export default { this.showPlugin() }, showPlugin3 () { + const _this = this this.$vux.confirm.prompt('123', { title: 'Title', onShow () { console.log('promt show') + _this.$vux.confirm.setInputValue('set input value') }, onHide () { console.log('prompt hide') diff --git a/src/plugins/confirm/index.js b/src/plugins/confirm/index.js index 0989552cf..d97e5883d 100644 --- a/src/plugins/confirm/index.js +++ b/src/plugins/confirm/index.js @@ -43,6 +43,13 @@ const plugin = { }) $vm.showValue = true }, + setInputValue (val) { + vue.nextTick(() => { + setTimeout(() => { + $vm.setInputValue(val) + }, 10) + }) + }, prompt (placeholder, options) { this.show(Object.assign({}, options, { placeholder,