Current location - Health Preservation Learning Network - Healthy weight loss - Element -Ui component message box popup window
Element -Ui component message box popup window
Official documents? . eleme . io/#/zh-CN/component/message-box

Basic usage

Message prompt box

```

Click to open the message box exportdefault {methods: {? Open() {this。 $alert ('This is a paragraph',' Title name', {? ConfirmButtonText:' OK ',? Callback: action =>{ This. $message({? Type:' info', message: `action: $ {action }`}); ? } }); ? } }? }

Click to open the message box exportdefault {methods: {open () {this. $ alert ('This is a paragraph',' Title name', {confirmButtonText:' OK', callback:action =>;; {this. $message({ type:'info ',message:` action:$ { action } `}); } }); }}} Click to open the message boxexportdefault {methods: {open () {this. $ alert ('This is a paragraph',' Title name', {confirmButtonText:' OK', callback:action =>;; {this. $message({ type:'info ',message:` action:$ { action } `}); } }); }}}< Template & gt

? & ltEl-button type = " text " @ click = " open " & gt; Click to open the message box.

& lt/template & gt;

& lt script & gt

? Export default value {

Method: {

? open() {

This. $alert ('This is a paragraph',' Title name', {

? ConfirmButtonText:' OK',

? Callback: action =>{

This. $message({

? Type: Information,

? Message: `Action: $ ${ action}'

});

? }

});

? }

}

? }

& lt/script & gt;

```

Pop up confirmation message

```

? Click to open the message box exportdefault {methods: {? Open2() {this。 $confirm ('This operation will permanently delete the file, do you want to continue?' 、' prompt '、{confirmButtonText:' OK ',cancelButtonText:' Cancel ',type:'warning'})。 Then (() =>{ this. $ message ({type:' Success', message:' Successfully deleted!' }); }).catch(()= & gt; {this. $ message ({type:' info ',message:' deleted ' }); ? }); ? } }? }

& lt template & gt

? & ltEl-button type = " text " @ click = " open 2 " & gt; Click to open the message box.

& lt/template & gt;

& lt script & gt

? Export default value {

Method: {

? open2() {

This. $confirm ('This operation will permanently delete the file, do you want to continue?' ,' Prompt', {

? ConfirmButtonText:' OK',

? CancelButtonText:' Cancel',

? Type: "Warning"

}). Then (() =>{

? This. $message({

Type: "Success",

Message: "Delete succeeded!"

? });

}).catch(()= & gt; {

? This. $message({

Type: Information,

Message: "Delete cancelled"

? }); ?

});

? }

}

? }

& lt/script & gt;

```

Submit content item symbol box

```

? Click to open the message box exportdefault {methods: {? Open3() {this。 $prompt ('Please enter email',' prompt', {confirmButtonText:' OK', cancelButtonText:' Cancel', inputPattern:/[\w! # $ % & amp'*+/=? ^_`{|}~-]+(? :\.【\w! # $ % & amp'*+/=? ^_`{|}~-]+)*@(? :[\w](? :[\w-]*[\w])? \.)+[\w](? :[\w-]*[\w])? /,inputErrorMessage: "Incorrect mailbox format"}). Then (({value })=>;; {this. $ message ({type:' success', message:' Your email address is:' +value? }); }).catch(()= & gt; {this. $ message ({type:' info', message:' cancel input'}); ? }); ? } }? }

& lt template & gt

? & ltEl-button type = " text " @ click = " open 3 " & gt; Click to open the message box.

& lt/template & gt;

& lt script & gt

? Export default value {

Method: {

? open3() {

This. $prompt ('Please enter email',' prompt', {

? ConfirmButtonText:' OK',

? CancelButtonText:' Cancel',

? inputPattern: /[\w! # $ % & amp'*+/=? ^_`{|}~-]+(? :\.【\w! # $ % & amp'*+/=? ^_`{|}~-]+)*@(? :[\w](? :[\w-]*[\w])? \.)+[\w](? :[\w-]*[\w])? /,

? InputErrorMessage: "Incorrect mailbox format"

}). Then (({value })=>;; {

? This. $message({

Type: "Success",

Message:' Your email address is' +value.

? });

}).catch(()= & gt; {

? This. $message({

Type: Information,

Message: "Cancel input"

? }); ?

});

? }

}

? }

& lt/script & gt;

```

Custom bullet box

```

? Click to open the message box exportdefault {methods: {? open4() {consth =this。 $ createElement, this. $msgbox({title:' message ',message: h ('p ',null,[h ('span ',null,' content can '),h ('i ',{style:' color: teal'},' vnode ')? ]), showcancelbutton: true, confirmbuttontext:' OK', cancelButtonText:' Cancel', before closing: (action, instance, done) = > {if (action = =' confirm') {? instance . confirm button loading = true; ? Instance.confirmButtonText =' Running ...'; ? setTimeout(()= & gt; { done(); setTimeout(()= & gt; { ? instance . confirm button loading = false; },300); ? },3000); } else { done(); } ? }}). Then (action =>{ this. $message({ type:'info ',message:'action: '+ action? }); }); ? } }? }

& lt template & gt

? & ltEl-button type = " text " @ click = " open 4 " & gt; Click to open the message box.

& lt/template & gt;

& lt script & gt

? Export default value {

Method: {

? open4() {

const h = this。 $ createElement

This. $msgbox({

? Title: "Message",

? Message: h('p', null, [

H('span', null,' content can be'),

h('i ',{ style: 'color: teal' },' VNode ')

? ]),

? showCancelButton: true,

? ConfirmButtonText:' OK',

? CancelButtonText:' Cancel',

? beforeClose: (action,instance,done)= & gt; {

if (action === 'confirm') {

? instance . confirm button loading = true;

? Instance.confirmButtonText =' Running ...';

? setTimeout(()= & gt; {

done();

setTimeout(()= & gt; {

? instance . confirm button loading = false;

}, 300);

? }, 3000);

} Otherwise {

? done();

}

? }

}). Then (action =>{

? This. $message({

Type: Information,

Message:' Action:'+Action

? });

});

? }

}

? }

& lt/script & gt;

```

Options:

The parameter type describes the optional value default value.

TitleMessageBox title string-

MessageMessageBox message body content string /vnode-

Does dangerouslyUseHTMLString regard the message attribute as an HTML fragment Boolean value-—false?

Type message type, used to display icon string success/information/warning/error—

CustomClassMessageBox's custom class name string-

Callback If you don't use Promise, you can use this parameter to specify the callback function (action, instance) after the MessageBox is closed. The value of action is' confirm' or' cancel', and instance is a MessageBox instance, through which you can access the properties and methods on the instance.

Does showCloseMessageBox display the close button boolean-true in the upper right corner?

The callback before closing beforeCloseMessageBox will suspend the closing function (action, instance, done) of the instance, and the value of action is' confirm' or' cancel ';; An instance is a MessageBox instance, through which you can access the properties and methods on the instance; Done is used to close the MessageBox instance-

Whether lockScroll locks the text to scroll is true when the message box is displayed as a Boolean value.

Whether showCancelButton displays the cancel button Boolean value-—false (true when called by confirmation and prompt)

Does showConfirmButton display the OK button Boolean value-really?

Text of the Cancel button string—Cancel.

ConfirmButtonText determines the text content of the button string-ok.

Custom Category Name String-Cancel Button Category Cancel Button's

Determines the custom class name string of the button.

Whether closeOnClickModal can close messagebox boolean-true (false when called in alarm mode) by clicking the mask.

CloseOnPressEscape whether the MessageBoxboolean—true closed by pressing ESC Boolean-true (false when called in alarm mode).

CloseOnhashchange Whether to close MessageBoxBoolean-true when hashchange.

Whether showInput displays input box Boolean value-—false (true when called in prompt mode)

Placeholder string —— Enter the.

Input Type Input Text Box String-Text

Initial text string of input value input box-

Check the expression regexp of the input mode input box.

Check the function of the inputValidator input box. You can return a Boolean value or a string. If a string is returned, the returned result will be assigned to inputerrormessagefunction-

Prompt text string-when the verification of inputErrorMessage fails-the input data is illegal!

Is the center centered boolean false?

Whether the roundButton uses the round button Boolean value-—false.