Skip to content

Commit

Permalink
confirm: add isVisible function for ConfirmPlugin #2704
Browse files Browse the repository at this point in the history
  • Loading branch information
airyland committed Apr 28, 2018
1 parent 98c6947 commit 2e31949
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/confirm/metas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ methods:
en: set input value when show-input is true
zh-CN: 设置输入值,当 show-input 为 true 时有效
changes:
next:
en:
- '[feature] add isVisible function for ConfirmPlugin #2704'
zh-CN:
- '[feature] 添加 isVisible 获取当前显示状态 #2704'
v2.9.0:
en:
- '[fix] fix inputAttrs issue with no-default-value #2618'
Expand Down
8 changes: 8 additions & 0 deletions src/demos/Confirm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,14 @@ export default {
}
})
}
},
mounted () {
this.timer = setInterval(() => {
console.log(this.$vux.confirm.isVisible())
}, 1000)
},
beforeDestroy () {
clearInterval(this.timer)
}
}
</script>
7 changes: 7 additions & 0 deletions src/plugins/confirm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import ConfirmComponent from '../../components/confirm'
import { mergeOptions } from '../../libs/plugin_helper'

let $vm
let isVisible = false

const plugin = {
install (vue, options = {}) {
Expand All @@ -28,6 +29,7 @@ const plugin = {
this.$watcher && this.$watcher()
this.$watcher = $vm.$watch('showValue', (val) => {
if (!val && options && options.onHide) {
isVisible = false
options.onHide()
}
})
Expand All @@ -42,6 +44,7 @@ const plugin = {
options && options.onConfirm && options.onConfirm(msg)
})
$vm.showValue = true
isVisible = true
},
setInputValue (val) {
vue.nextTick(() => {
Expand All @@ -58,6 +61,10 @@ const plugin = {
},
hide () {
$vm.showValue = false
isVisible = false
},
isVisible () {
return isVisible
}
}

Expand Down

0 comments on commit 2e31949

Please sign in to comment.