一、配置
ArgumentDefault valueDescription
title
null
模态对话框的标题。它可以在参数对象的title参数中设置,也可以在swal()方法的第一个参数设置。
The title of the modal, as HTML. It can either be added to the object under the key "title" or passed as the first parameter of the function.
titleText
null
模态对话框的内容。
The title of the modal, as text. Useful to avoid HTML injection.
text
null
模态对话框的内容。它可以在参数对象的text参数中设置,也可以在swal()方法的第二个参数设置。
A description for the modal. It can either be added to the object under the key "text" or passed as the second parameter of the function.
html
null
对话框中的内容作为HTML标签。如果同时提供text和html参数,插件将会优先使用text参数。
A HTML description for the modal. If "text" and "html" parameters are provided in the same time, "text" will be used.
type
null
对话框的情景类型。有5种内置的情景类型:warning,error,success,info和question。它可以在参数对象的type参数中设置,也可以在swal()方法的第三个参数设置。
The type of the modal. SweetAlert2 comes with 5 built-in types which will show a corresponding icon animation: warning, error, success, info and question. It can either be put in the array under the key "type" or passed as the third parameter of the function.
target
'body'
The container element for adding modal into.
input
null
表单input域的类型,可以是text, email, password,number, tel, range, textarea, select, radio,checkbox, file and url.
Input field type, can be text, email, password,number, tel, range, textarea, select, radio,checkbox, file and url.
width
'500px'
Modal window width, including paddings (box-sizing: border-box). Can be in px or %.
padding
20
Modal window padding.
background
'#fff'
Modal window background (CSS background property).
customClass
null
模态对话框的自定义class类。
A custom CSS class for the modal.
timer
null
Auto close timer of the modal. Set in ms (milli