Skip to content

Commit

Permalink
fix(ui/dialog picker): 优化close方法
Browse files Browse the repository at this point in the history
affects: @varlet/ui
  • Loading branch information
齐皓 authored and 齐皓 committed Feb 3, 2021
1 parent 0c78a72 commit 5b426ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 1 addition & 7 deletions packages/varlet-ui/src/dialog/example/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,10 @@ export default defineComponent({
message: '测试文字测试文字测试文字测试文字测试文字测试文字测试文字',
})
await Dialog({
title: '测试1',
title: '测试2',
cancelButton: false,
message: '测试文字测试文字测试文字测试文字测试文字测试文字测试文字',
})
// Dialog.close()
// Dialog({
// title: '测试2',
// cancelButton: false,
// message: '测试文字测试文字测试文字测试文字测试文字测试文字测试文字',
// })
// setTimeout(() => {
// Dialog.close()
Expand Down
7 changes: 5 additions & 2 deletions packages/varlet-ui/src/dialog/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { reactive, App } from 'vue'
import { reactive, App, nextTick } from 'vue'
import VarDialog from './Dialog.vue'
import { isString } from '../utils/shared'
import { mountInstance } from '../utils/components'
Expand Down Expand Up @@ -79,7 +79,10 @@ Dialog.install = function (app: App) {

Dialog.close = () => {
if (singletonOptions) {
singletonOptions.show = false
const options = singletonOptions
nextTick().then(() => {
options.show = false
})
singletonOptions = null
}
}
Expand Down
7 changes: 5 additions & 2 deletions packages/varlet-ui/src/picker/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { App, reactive } from 'vue'
import { App, nextTick, reactive } from 'vue'
import VarPicker from './Picker.vue'
import { NormalColumn, CascadeColumn } from './props'
import { isArray } from '../utils/shared'
Expand Down Expand Up @@ -97,7 +97,10 @@ Picker.install = function (app: App) {

Picker.close = () => {
if (singletonOptions) {
singletonOptions.show = false
const options = singletonOptions
nextTick().then(() => {
options.show = false
})
singletonOptions = null
}
}
Expand Down

0 comments on commit 5b426ab

Please sign in to comment.