-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
160 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,121 @@ | ||
<template> | ||
<Button @click="instance('info')">Info</Button> | ||
<Button @click="instance('success')">Success</Button> | ||
<Button @click="instance('warning')">Warning</Button> | ||
<Button @click="instance('error')">Error</Button> | ||
<Divider></Divider> | ||
<Button @click="confirm">Normal</Button> | ||
<Button @click="custom">Custom button text</Button> | ||
<Button @click="async">Asynchronous closing</Button> | ||
<p> | ||
Name: {{ value }} | ||
</p> | ||
<p> | ||
<Button @click="handleRender">Custom content</Button> | ||
</p> | ||
<template> | ||
<Modal | ||
v-model="visible" | ||
v-model:fullscreen-value="fullscreen" | ||
showFullscreenIcon | ||
:closable="true" | ||
title="Common Modal dialog box title" | ||
> | ||
<p>Content of dialog</p> | ||
<p>Content of dialog</p> | ||
<p>Content of dialog</p> | ||
</Modal> | ||
<Button @click="instance('info')">Info</Button> | ||
<Button @click="instance('success')">Success</Button> | ||
<Button @click="instance('warning')">Warning</Button> | ||
<Button @click="instance('error')">Error</Button> | ||
<Divider></Divider> | ||
<Button @click="confirm">Normal</Button> | ||
<Button @click="custom">Custom button text</Button> | ||
<Button @click="async">Asynchronous closing</Button> | ||
<p>Name: {{ value }}</p> | ||
<p> | ||
<Button @click="handleRender">Custom content</Button> | ||
</p> | ||
</template> | ||
<script> | ||
import ViewUI from '../../src/index'; | ||
import ViewUI from "../../src/index"; | ||
export default { | ||
data () { | ||
return { | ||
value: '' | ||
} | ||
data() { | ||
return { | ||
visible: true, | ||
fullscreen: false, | ||
value: "", | ||
}; | ||
}, | ||
methods: { | ||
changeFull() { | ||
this.$Message.info(this.fullscreen + ""); | ||
}, | ||
methods: { | ||
instance (type) { | ||
const title = 'Title'; | ||
const content = '<p>Content of dialog</p><p>Content of dialog</p>'; | ||
switch (type) { | ||
case 'info': | ||
this.$Modal.info({ | ||
title: title, | ||
content: content, | ||
onOk: () => { | ||
this.$Message.info('Clicked ok'); | ||
}, | ||
}); | ||
break; | ||
case 'success': | ||
this.$Modal.success({ | ||
title: title, | ||
content: content | ||
}); | ||
break; | ||
case 'warning': | ||
this.$Modal.warning({ | ||
title: title, | ||
content: content | ||
}); | ||
break; | ||
case 'error': | ||
this.$Modal.error({ | ||
title: title, | ||
content: content | ||
}); | ||
break; | ||
} | ||
instance(type) { | ||
const title = "Title"; | ||
const content = "<p>Content of dialog</p><p>Content of dialog</p>"; | ||
switch (type) { | ||
case "info": | ||
this.$Modal.info({ | ||
title: title, | ||
content: content, | ||
onOk: () => { | ||
this.$Message.info("Clicked ok"); | ||
}, | ||
}); | ||
break; | ||
case "success": | ||
this.$Modal.success({ | ||
title: title, | ||
content: content, | ||
}); | ||
break; | ||
case "warning": | ||
this.$Modal.warning({ | ||
title: title, | ||
content: content, | ||
}); | ||
break; | ||
case "error": | ||
this.$Modal.error({ | ||
title: title, | ||
content: content, | ||
}); | ||
break; | ||
} | ||
}, | ||
confirm() { | ||
this.$Modal.confirm({ | ||
title: "Title", | ||
content: "<p>Content of dialog</p><p>Content of dialog</p>", | ||
onOk: () => { | ||
this.$Message.info("Clicked ok"); | ||
}, | ||
confirm () { | ||
this.$Modal.confirm({ | ||
title: 'Title', | ||
content: '<p>Content of dialog</p><p>Content of dialog</p>', | ||
onOk: () => { | ||
this.$Message.info('Clicked ok'); | ||
}, | ||
onCancel: () => { | ||
this.$Message.info('Clicked cancel'); | ||
} | ||
}); | ||
onCancel: () => { | ||
this.$Message.info("Clicked cancel"); | ||
}, | ||
custom () { | ||
this.$Modal.confirm({ | ||
title: 'Title', | ||
content: '<p>Content of dialog</p><p>Content of dialog</p>', | ||
okText: 'OK', | ||
cancelText: 'Cancel' | ||
}); | ||
}); | ||
}, | ||
custom() { | ||
this.$Modal.confirm({ | ||
title: "Title", | ||
content: "<p>Content of dialog</p><p>Content of dialog</p>", | ||
okText: "OK", | ||
cancelText: "Cancel", | ||
}); | ||
}, | ||
async() { | ||
this.$Modal.confirm({ | ||
title: "Title", | ||
content: "<p>The dialog box will be closed after 2 seconds</p>", | ||
loading: true, | ||
onOk: () => { | ||
setTimeout(() => { | ||
this.$Modal.remove(); | ||
this.$Message.info("Asynchronously close the dialog box"); | ||
}, 2000); | ||
}, | ||
async () { | ||
this.$Modal.confirm({ | ||
title: 'Title', | ||
content: '<p>The dialog box will be closed after 2 seconds</p>', | ||
loading: true, | ||
onOk: () => { | ||
setTimeout(() => { | ||
this.$Modal.remove(); | ||
this.$Message.info('Asynchronously close the dialog box'); | ||
}, 2000); | ||
} | ||
}); | ||
}); | ||
}, | ||
handleRender() { | ||
this.$Modal.confirm({ | ||
render: (h) => { | ||
return h(ViewUI.Input, { | ||
// todo 不能直接写 'Input' ? | ||
modelValue: this.value, | ||
autofocus: true, | ||
placeholder: "Please enter your name...", | ||
"onUpdate:modelValue": (val) => (this.value = val), | ||
}); | ||
}, | ||
handleRender () { | ||
this.$Modal.confirm({ | ||
render: (h) => { | ||
return h(ViewUI.Input, { // todo 不能直接写 'Input' ? | ||
modelValue: this.value, | ||
autofocus: true, | ||
placeholder: 'Please enter your name...', | ||
'onUpdate:modelValue': (val) => this.value = val | ||
}) | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
}); | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters