|
|
@@ -24,14 +24,17 @@ app.use(Dialog).use(Popup).use(OverLay)
|
|
|
```html
|
|
|
<template>
|
|
|
<nut-cell-group title="Function Use">
|
|
|
- <nut-cell title="Title" @click="baseClick"></nut-cell>
|
|
|
- <nut-cell title="Title" @click="noTitleClick"></nut-cell>
|
|
|
- <nut-cell title="Title" @click="tipsClick"></nut-cell>
|
|
|
- <nut-cell title="Title" @click="verticalClick"></nut-cell>
|
|
|
-</nut-cell-group>
|
|
|
+ <nut-cell title="Basic Usage" @click="baseClick"></nut-cell>
|
|
|
+ <nut-cell title="Transparent Dialog" @click="transparentClick"></nut-cell>
|
|
|
+ <nut-cell title="Use html" @click="htmlClick"></nut-cell>
|
|
|
+ <nut-cell title="Before Close" @click="beforeCloseClick"></nut-cell>
|
|
|
+ <nut-cell title="No Title" @click="noTitleClick"></nut-cell>
|
|
|
+ <nut-cell title="Tips Dialog" @click="tipsClick"></nut-cell>
|
|
|
+ <nut-cell title="Bottom button vertical use" @click="verticalClick"></nut-cell>
|
|
|
+ </nut-cell-group>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
-import { ref } from 'vue';
|
|
|
+import { ref,createVNode } from 'vue';
|
|
|
import { Dialog } from '@nutui/nutui';
|
|
|
export default {
|
|
|
setup() {
|
|
|
@@ -49,6 +52,39 @@ export default {
|
|
|
onOk
|
|
|
});
|
|
|
};
|
|
|
+ const transparentClick = (): void => {
|
|
|
+ Dialog({
|
|
|
+ overlayStyle: { background: 'rgba(0,0,0,0)' },
|
|
|
+ title: 'Transparent Dialog',
|
|
|
+ content: 'Content',
|
|
|
+ onCancel,
|
|
|
+ onOk
|
|
|
+ });
|
|
|
+ };
|
|
|
+ const htmlClick = (): void => {
|
|
|
+ Dialog({
|
|
|
+ title: "Use html",
|
|
|
+ content:
|
|
|
+ "<p style='color:red'>html</p><img src='https://m.360buyimg.com/babel/jfs/t1/164410/22/25162/93384/616eac6cE6c711350/0cac53c1b82e1b05.gif' />",
|
|
|
+ onCancel,
|
|
|
+ onOk
|
|
|
+ });
|
|
|
+ };
|
|
|
+ const beforeCloseClick = (): void => {
|
|
|
+ Dialog({
|
|
|
+ title: 'Before Close',
|
|
|
+ content: 'Click confirm to close it in 1 second',
|
|
|
+ onCancel,
|
|
|
+ onOk,
|
|
|
+ beforeClose: (action: string) => {
|
|
|
+ return new Promise((r) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ r(action == 'ok');
|
|
|
+ }, 1000);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
const noTitleClick = () => {
|
|
|
Dialog({
|
|
|
content: 'Content',
|
|
|
@@ -76,6 +112,9 @@ export default {
|
|
|
};
|
|
|
return {
|
|
|
baseClick,
|
|
|
+ transparentClick,
|
|
|
+ htmlClick,
|
|
|
+ beforeCloseClick,
|
|
|
noTitleClick,
|
|
|
tipsClick,
|
|
|
verticalClick
|
|
|
@@ -168,57 +207,67 @@ export default {
|
|
|
:::
|
|
|
|
|
|
## API
|
|
|
-| Attribute | Description | Type | Default |
|
|
|
-|----------------------|--------------------------------------------------------------------------------|------------------|----------------------|
|
|
|
-| title | Title | String | - |
|
|
|
-| id | Identifier, share one instance at the same time, default to multiple instances | String or Number | new Date().getTime() |
|
|
|
-| content | Content, support HTML | String | - |
|
|
|
-| teleport | Specifies a target element where Dialog will be mounted | String | "body" |
|
|
|
-| closeOnClickOverlay | Whether to close when overlay is clicked | Boolean | false |
|
|
|
-| noFooter | Hide bottom button bar | Boolean | false |
|
|
|
-| noOkBtn | Hide OK button | Boolean | false |
|
|
|
-| noCancelBtn | Hide cancel button | Boolean | false |
|
|
|
-| cancelText | Cancel button text | String | "Cancel" |
|
|
|
-| okText | OK button text | String | "Confirm" |
|
|
|
-| cancelAutoClose | Click Cancel to close the popup | Boolean | true |
|
|
|
-| textAlign | Text alignment direction, the optional value is the same as css text-align | String | "center" |
|
|
|
-| closeOnPopstate | Whether to close when popstate | Boolean | false |
|
|
|
-| customClass`v3.1.22` | Custom dialog class | String | |
|
|
|
-| onUpdate | Update | Boolean | false |
|
|
|
-| onOk | Emitted when the confirm button is clicked | Function | - |
|
|
|
-| onCancel | Emitted when the cancel button is clicked | Function | - |
|
|
|
-| onClosed | Emitted when Dialog is closed | Function | - |
|
|
|
+| Attribute | Description | Type | Default |
|
|
|
+|-----------------------|--------------------------------------------------------------------------------|--------------------------|----------------------|
|
|
|
+| title | Title | String | - |
|
|
|
+| id | Identifier, share one instance at the same time, default to multiple instances | String or Number | new Date().getTime() |
|
|
|
+| content | Content, support HTML | String | - |
|
|
|
+| teleport | Specifies a target element where Dialog will be mounted | String | "body" |
|
|
|
+| closeOnClickOverlay | Whether to close when overlay is clicked | Boolean | false |
|
|
|
+| noFooter | Hide bottom button bar | Boolean | false |
|
|
|
+| noOkBtn | Hide OK button | Boolean | false |
|
|
|
+| noCancelBtn | Hide cancel button | Boolean | false |
|
|
|
+| cancelText | Cancel button text | String | "Cancel" |
|
|
|
+| okText | OK button text | String | "Confirm" |
|
|
|
+| cancelAutoClose | Click Cancel to close the popup | Boolean | true |
|
|
|
+| textAlign | Text alignment direction, the optional value is the same as css text-align | String | "center" |
|
|
|
+| closeOnPopstate | Whether to close when popstate | Boolean | false |
|
|
|
+| customClass`v3.1.22` | Custom dialog class | String | |
|
|
|
+| overlayClass`v3.1.22` | Custom mask classname | String | - |
|
|
|
+| overlayStyle`v3.1.22` | Custom mask styles | CSSProperties | - |
|
|
|
+| popClass `v3.1.22` | Custom popup classname | String | - |
|
|
|
+| popStyle `v3.1.22` | Custom popup styles | CSSProperties | - |
|
|
|
+| onUpdate | Update | Boolean | false |
|
|
|
+| onOk | Emitted when the confirm button is clicked | Function | - |
|
|
|
+| onCancel | Emitted when the cancel button is clicked | Function | - |
|
|
|
+| onOpened`v3.1.22` | Emitted when Dialog is opened | Function | - |
|
|
|
+| onClosed | Emitted when Dialog is closed | Function | - |
|
|
|
+| beforeClose`v3.1.22` | Callback function before close support return `promise` | Function(action: string) | - |
|
|
|
|
|
|
|
|
|
## Props
|
|
|
|
|
|
-| Attribute | Description | Type | Default |
|
|
|
-|------------------------|-----------------------------------------------------------------------------------------------------------|---------------|------------|
|
|
|
-| title | Title | String | - |
|
|
|
-| content | Content, support HTML | String | - |
|
|
|
-| teleport | Specifies a target element where Dialog will be mounted | String | "body" |
|
|
|
-| close-on-click-overlay | Whether to close when overlay is clicked | Boolean | false |
|
|
|
-| no-footer | Hide bottom button bar | Boolean | false |
|
|
|
-| no-ok-btn | Hide OK button | Boolean | false |
|
|
|
-| no-cancel-btn | Hide cancel button | Boolean | false |
|
|
|
-| cancel-text | Cancel button text | String | "Cancel" |
|
|
|
-| ok-text | OK button text | String | "Confirm" |
|
|
|
-| cancel-auto-close | Click Cancel to close the popup | Boolean | true |
|
|
|
-| text-align | Text alignment direction, the optional value is the same as css text-align | String | "center" |
|
|
|
-| close-on-popstate | Whether to close when popstate | Boolean | false |
|
|
|
-| lock-scroll | Whether to lock background scroll | Boolean | false |
|
|
|
-| footer-direction | The bottom button uses the horizontal and vertical directions. Optional values are horizontal and vertical. | string | horizontal |
|
|
|
-| overlay-class`v3.1.21` | Custom mask classname | String | - |
|
|
|
-| overlay-style`v3.1.21` | Custom mask styles | CSSProperties | - |
|
|
|
-| custom-class`v3.1.22` | Custom dialog class | String | - |
|
|
|
+| Attribute | Description | Type | Default |
|
|
|
+|------------------------|-----------------------------------------------------------------------------------------------------------|--------------------------|------------|
|
|
|
+| title | Title | String | - |
|
|
|
+| content | Content, support HTML | String | - |
|
|
|
+| teleport | Specifies a target element where Dialog will be mounted | String | "body" |
|
|
|
+| close-on-click-overlay | Whether to close when overlay is clicked | Boolean | false |
|
|
|
+| no-footer | Hide bottom button bar | Boolean | false |
|
|
|
+| no-ok-btn | Hide OK button | Boolean | false |
|
|
|
+| no-cancel-btn | Hide cancel button | Boolean | false |
|
|
|
+| cancel-text | Cancel button text | String | "Cancel" |
|
|
|
+| ok-text | OK button text | String | "Confirm" |
|
|
|
+| cancel-auto-close | Click Cancel to close the popup | Boolean | true |
|
|
|
+| text-align | Text alignment direction, the optional value is the same as css text-align | String | "center" |
|
|
|
+| close-on-popstate | Whether to close when popstate | Boolean | false |
|
|
|
+| lock-scroll | Whether to lock background scroll | Boolean | false |
|
|
|
+| footer-direction | The bottom button uses the horizontal and vertical directions. Optional values are horizontal and vertical. | string | horizontal |
|
|
|
+| overlay-class`v3.1.22` | Custom mask classname | String | - |
|
|
|
+| overlay-style`v3.1.22` | Custom mask styles | CSSProperties | - |
|
|
|
+| pop-class `v3.1.22` | Custom popup classname | String | - |
|
|
|
+| pop-style `v3.1.22` | Custom popup styles | CSSProperties | - |
|
|
|
+| custom-class`v3.1.22` | Custom dialog class | String | - |
|
|
|
+| before-close`v3.1.22` | Callback function before close support return `promise` | Function(action: string) | - |
|
|
|
|
|
|
## Events
|
|
|
|
|
|
-| Event | Description | Type | Default |
|
|
|
-|--------|--------------------------------------------|----------|---------|
|
|
|
-| ok | Emitted when the confirm button is clicked | Function | - |
|
|
|
-| cancel | Emitted when the cancel button is clicked | Function | - |
|
|
|
-| closed | Emitted when Dialog is closed | Function | - |
|
|
|
+| Event | Description | Type | Default |
|
|
|
+|-----------------|--------------------------------------------|----------|---------|
|
|
|
+| ok | Emitted when the confirm button is clicked | Function | - |
|
|
|
+| cancel | Emitted when the cancel button is clicked | Function | - |
|
|
|
+| closed | Emitted when Dialog is closed | Function | - |
|
|
|
+| opened`v3.1.22` | Emitted when Dialog is Opened | Function | - |
|
|
|
|
|
|
|
|
|
## Slots
|