mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[new feature] Dialog: add message-align prop (#2259)
This commit is contained in:
parent
792fd3fe6f
commit
4fe387b7b1
@ -17,7 +17,7 @@
|
|||||||
<div
|
<div
|
||||||
v-if="message"
|
v-if="message"
|
||||||
v-html="message"
|
v-html="message"
|
||||||
:class="b('message', { 'has-title': title })"
|
:class="b('message', { 'has-title': title, [messageAlign]: messageAlign })"
|
||||||
/>
|
/>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
@ -68,6 +68,7 @@ export default create({
|
|||||||
callback: Function,
|
callback: Function,
|
||||||
className: [String, Object, Array],
|
className: [String, Object, Array],
|
||||||
beforeClose: Function,
|
beforeClose: Function,
|
||||||
|
messageAlign: String,
|
||||||
confirmButtonText: String,
|
confirmButtonText: String,
|
||||||
cancelButtonText: String,
|
cancelButtonText: String,
|
||||||
showCancelButton: Boolean,
|
showCancelButton: Boolean,
|
||||||
|
@ -11,6 +11,7 @@ Vue.use(Dialog);
|
|||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
#### Alert dialog
|
#### Alert dialog
|
||||||
|
|
||||||
Used to prompt for some messages, only including one confirm button
|
Used to prompt for some messages, only including one confirm button
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
@ -29,6 +30,7 @@ Dialog.alert({
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Confirm dialog
|
#### Confirm dialog
|
||||||
|
|
||||||
Used to confirm some messages, including a confirm button and a cancel button
|
Used to confirm some messages, including a confirm button and a cancel button
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
@ -43,6 +45,7 @@ Used to confirm some messages, including a confirm button and a cancel button
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### $dialog Method
|
#### $dialog Method
|
||||||
|
|
||||||
After import the Dialog component, the $dialog method is automatically mounted on Vue.prototype, making it easy to call within a vue component.
|
After import the Dialog component, the $dialog method is automatically mounted on Vue.prototype, making it easy to call within a vue component.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@ -72,6 +75,7 @@ export default {
|
|||||||
|------|------|------|------|
|
|------|------|------|------|
|
||||||
| title | Title | `String` | - |
|
| title | Title | `String` | - |
|
||||||
| message | Message | `String` | - |
|
| message | Message | `String` | - |
|
||||||
|
| messageAlign | Message text align,can be set to `left` `right` | `String` | `center` |
|
||||||
| className | Custom className | `String | Array | Object` | - |
|
| className | Custom className | `String | Array | Object` | - |
|
||||||
| showConfirmButton | Whether to show confirm button | `Boolean` | `true` |
|
| showConfirmButton | Whether to show confirm button | `Boolean` | `true` |
|
||||||
| showCancelButton | Whether to show cancel button | `Boolean` | `false` |
|
| showCancelButton | Whether to show cancel button | `Boolean` | `false` |
|
||||||
@ -83,6 +87,7 @@ export default {
|
|||||||
| beforeClose | Callback before close,<br>call done() to close dialog,<br>call done(false) to cancel loading | (action: string, done: function) => void | - |
|
| beforeClose | Callback before close,<br>call done() to close dialog,<br>call done(false) to cancel loading | (action: string, done: function) => void | - |
|
||||||
|
|
||||||
#### Advanced Usage
|
#### Advanced Usage
|
||||||
|
|
||||||
If you need to render vue components within a dialog, you can use dialog component.
|
If you need to render vue components within a dialog, you can use dialog component.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
@ -132,7 +137,7 @@ export default {
|
|||||||
| v-model | Whether to show dialog | `Boolean` | - |
|
| v-model | Whether to show dialog | `Boolean` | - |
|
||||||
| title | Title | `String` | - |
|
| title | Title | `String` | - |
|
||||||
| message | Message | `String` | - |
|
| message | Message | `String` | - |
|
||||||
| async-confirm | Whether to close async,The incoming function is triggered when you click confirm. | `Function` | - |
|
| message-align | Message align,can be set to `left` `right` | `String` | `center` |
|
||||||
| show-confirm-button | Whether to show confirm button | `Boolean` | `true` |
|
| show-confirm-button | Whether to show confirm button | `Boolean` | `true` |
|
||||||
| show-cancel-button | Whether to show cancel button | `Boolean` | `false` |
|
| show-cancel-button | Whether to show cancel button | `Boolean` | `false` |
|
||||||
| confirm-button-text | Confirm button text | `String` | `Confirm` |
|
| confirm-button-text | Confirm button text | `String` | `Confirm` |
|
||||||
|
@ -44,6 +44,7 @@ Dialog.defaultOptions = {
|
|||||||
className: '',
|
className: '',
|
||||||
lockScroll: true,
|
lockScroll: true,
|
||||||
beforeClose: null,
|
beforeClose: null,
|
||||||
|
messageAlign: '',
|
||||||
confirmButtonText: '',
|
confirmButtonText: '',
|
||||||
cancelButtonText: '',
|
cancelButtonText: '',
|
||||||
showConfirmButton: true,
|
showConfirmButton: true,
|
||||||
|
@ -28,12 +28,21 @@
|
|||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
max-height: 60vh;
|
max-height: 60vh;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
text-align: center;
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
|
|
||||||
&--has-title {
|
&--has-title {
|
||||||
padding-top: 12px;
|
padding-top: 12px;
|
||||||
color: @gray-darker;
|
color: @gray-darker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&--left {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
&--right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__footer {
|
&__footer {
|
||||||
|
@ -12,6 +12,7 @@ Vue.use(Dialog);
|
|||||||
### 代码演示
|
### 代码演示
|
||||||
|
|
||||||
#### 消息提示
|
#### 消息提示
|
||||||
|
|
||||||
用于提示一些消息,只包含一个确认按钮
|
用于提示一些消息,只包含一个确认按钮
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
@ -30,6 +31,7 @@ Dialog.alert({
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### 消息确认
|
#### 消息确认
|
||||||
|
|
||||||
用于确认消息,包含取消和确认按钮
|
用于确认消息,包含取消和确认按钮
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
@ -44,6 +46,7 @@ Dialog.confirm({
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### 全局方法
|
#### 全局方法
|
||||||
|
|
||||||
引入 Dialog 组件后,会自动在 Vue 的 prototype 上挂载 $dialog 方法,在所有组件内部都可以直接调用此方法
|
引入 Dialog 组件后,会自动在 Vue 的 prototype 上挂载 $dialog 方法,在所有组件内部都可以直接调用此方法
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@ -73,6 +76,7 @@ export default {
|
|||||||
|------|------|------|------|------|
|
|------|------|------|------|------|
|
||||||
| title | 标题 | `String` | - | - |
|
| title | 标题 | `String` | - | - |
|
||||||
| message | 内容 | `String` | - | - |
|
| message | 内容 | `String` | - | - |
|
||||||
|
| messageAlign | 内容对齐方式,可选值为`left` `right` | `String` | `center` | 1.4.10 |
|
||||||
| className | 自定义类名 | `String | Array | Object` | - | 1.1.7 |
|
| className | 自定义类名 | `String | Array | Object` | - | 1.1.7 |
|
||||||
| showConfirmButton | 是否展示确认按钮 | `Boolean` | `true` | - |
|
| showConfirmButton | 是否展示确认按钮 | `Boolean` | `true` | - |
|
||||||
| showCancelButton | 是否展示取消按钮 | `Boolean` | `false` | - |
|
| showCancelButton | 是否展示取消按钮 | `Boolean` | `false` | - |
|
||||||
@ -136,6 +140,7 @@ export default {
|
|||||||
| v-model | 是否显示弹窗 | `Boolean` | - | - |
|
| v-model | 是否显示弹窗 | `Boolean` | - | - |
|
||||||
| title | 标题 | `String` | - | - |
|
| title | 标题 | `String` | - | - |
|
||||||
| message | 内容 | `String` | - | - |
|
| message | 内容 | `String` | - | - |
|
||||||
|
| message-align | 内容对齐方式,可选值为`left` `right` | `String` | `center` | 1.4.10 |
|
||||||
| show-confirm-button | 是否展示确认按钮 | `Boolean` | `true` | - |
|
| show-confirm-button | 是否展示确认按钮 | `Boolean` | `true` | - |
|
||||||
| show-cancel-button | 是否展示取消按钮 | `Boolean` | `false` | - |
|
| show-cancel-button | 是否展示取消按钮 | `Boolean` | `false` | - |
|
||||||
| confirm-button-text | 确认按钮的文案 | `String` | `确认` | - |
|
| confirm-button-text | 确认按钮的文案 | `String` | `确认` | - |
|
||||||
|
1
types/dialog.d.ts
vendored
1
types/dialog.d.ts
vendored
@ -7,6 +7,7 @@ export type DialogOptions = {
|
|||||||
overlay?: boolean;
|
overlay?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
lockScroll?: boolean;
|
lockScroll?: boolean;
|
||||||
|
messageAlign?: string;
|
||||||
confirmButtonText?: string;
|
confirmButtonText?: string;
|
||||||
cancelButtonText?: string;
|
cancelButtonText?: string;
|
||||||
showConfirmButton?: boolean;
|
showConfirmButton?: boolean;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user