-
Notifications
You must be signed in to change notification settings - Fork 0
/
23-a28f22da2d828c0b81f9.js
1 lines (1 loc) · 37.9 KB
/
23-a28f22da2d828c0b81f9.js
1
webpackJsonp([23],{1581:function(n,a,t){"use strict";function s(n){return n&&n.__esModule?n:{default:n}}function p(n){return w.default.createElement(n.tag,(0,l.default)({},n.attributes,{dangerouslySetInnerHTML:{__html:n.html}}))}function o(n){return w.default.createElement(p,{tag:"section",html:n.html,attributes:{className:"zandoc-react-markdown"}})}function e(n){return w.default.createElement(p,{tag:"style",html:n.style})}function c(n,a){for(;n;)return n.offsetTop&&"static"!==getComputedStyle(n).position&&(a+=n.offsetTop),c(n.parentNode,a);return a}Object.defineProperty(a,"__esModule",{value:!0});var u=t(7),l=s(u),i=t(1),r=s(i),k=t(4),d=s(k),f=t(2),m=s(f),h=t(3),g=s(h),y=t(0),w=s(y),C=t(232),v=s(C),_=t(359),b=function(){var n=function(n){function a(){var n,t,s,p;(0,r.default)(this,a);for(var o=arguments.length,e=Array(o),c=0;c<o;c++)e[c]=arguments[c];return t=s=(0,m.default)(this,(n=a.__proto__||Object.getPrototypeOf(a)).call.apply(n,[this].concat(e))),s.showAlertInfo=function(){_.Sweetalert.alert({content:"这个是具体内容",parentComponent:s})},p=t,(0,m.default)(s,p)}return(0,g.default)(a,n),(0,d.default)(a,[{key:"render",value:function(){return w.default.createElement(_.Button,{onClick:this.showAlertInfo},"消息对话框")}}]),a}(w.default.Component);return w.default.createElement(n,null)},E=function(){var n=function(n){function a(){var n,t,s,p;(0,r.default)(this,a);for(var o=arguments.length,e=Array(o),c=0;c<o;c++)e[c]=arguments[c];return t=s=(0,m.default)(this,(n=a.__proto__||Object.getPrototypeOf(a)).call.apply(n,[this].concat(e))),s.onConfirm=function(){_.Notify.success("我真的知道了")},s.onCancel=function(){_.Notify.error("我真的取消了")},s.showAlertConfirm=function(){_.Sweetalert.confirm({content:w.default.createElement("p",null,"这个是内容"),onConfirm:s.onConfirm,onCancel:s.onCancel,parentComponent:s})},p=t,(0,m.default)(s,p)}return(0,g.default)(a,n),(0,d.default)(a,[{key:"render",value:function(){return w.default.createElement(_.Button,{onClick:this.showAlertConfirm},"消息对话框")}}]),a}(w.default.Component);return w.default.createElement(n,null)},B=function(){var n=function(n){function a(){var n,t,s,p;(0,r.default)(this,a);for(var o=arguments.length,e=Array(o),c=0;c<o;c++)e[c]=arguments[c];return t=s=(0,m.default)(this,(n=a.__proto__||Object.getPrototypeOf(a)).call.apply(n,[this].concat(e))),s.autoCloseConfirm=function(){var n=_.Sweetalert.confirm({content:w.default.createElement("p",null,"一秒后自动关闭"),parentComponent:s});setTimeout(n,1e3)},p=t,(0,m.default)(s,p)}return(0,g.default)(a,n),(0,d.default)(a,[{key:"render",value:function(){return w.default.createElement(_.Button,{onClick:this.autoCloseConfirm},"自动关闭对话框")}}]),a}(w.default.Component);return w.default.createElement(n,null)},A=function(){var n=function(n){function a(){var n,t,s,p;(0,r.default)(this,a);for(var o=arguments.length,e=Array(o),c=0;c<o;c++)e[c]=arguments[c];return t=s=(0,m.default)(this,(n=a.__proto__||Object.getPrototypeOf(a)).call.apply(n,[this].concat(e))),s.promiseConfirm=function(){_.Sweetalert.confirm({content:"点击确定后三秒自动关闭",title:"onConfirm返回Promise",onConfirm:function(){return new Promise(function(n){setTimeout(function(){n()},3e3)})},parentComponent:s})},p=t,(0,m.default)(s,p)}return(0,g.default)(a,n),(0,d.default)(a,[{key:"render",value:function(){return w.default.createElement(_.Button,{onClick:this.promiseConfirm},"自动关闭对话框(Promise)")}}]),a}(w.default.Component);return w.default.createElement(n,null)},N=function(){var n=function(n){function a(){var n,t,s,p;(0,r.default)(this,a);for(var o=arguments.length,e=Array(o),c=0;c<o;c++)e[c]=arguments[c];return t=s=(0,m.default)(this,(n=a.__proto__||Object.getPrototypeOf(a)).call.apply(n,[this].concat(e))),s.showAlertInfo=function(){_.Sweetalert.alert({type:"info",content:"这个是具体内容",title:"这是一个消息标题",parentComponent:s})},p=t,(0,m.default)(s,p)}return(0,g.default)(a,n),(0,d.default)(a,[{key:"render",value:function(){return w.default.createElement(_.Button,{onClick:this.showAlertInfo},"含有图标消息对话框")}}]),a}(w.default.Component);return w.default.createElement(n,null)},S=function(){var n=function(n){function a(){var n,t,s,p;(0,r.default)(this,a);for(var o=arguments.length,e=Array(o),c=0;c<o;c++)e[c]=arguments[c];return t=s=(0,m.default)(this,(n=a.__proto__||Object.getPrototypeOf(a)).call.apply(n,[this].concat(e))),s.showAlertConfirm=function(){_.Sweetalert.confirm({confirmType:"danger",confirmText:"删除",cancelText:"取消",content:"确认删除吗?",title:"请确认",parentComponent:s})},p=t,(0,m.default)(s,p)}return(0,g.default)(a,n),(0,d.default)(a,[{key:"render",value:function(){return w.default.createElement(_.Button,{onClick:this.showAlertConfirm,type:"danger"},"删除")}}]),a}(w.default.Component);return w.default.createElement(n,null)},j=function(){var n=function(n){function a(){var n,t,s,p;(0,r.default)(this,a);for(var o=arguments.length,e=Array(o),c=0;c<o;c++)e[c]=arguments[c];return t=s=(0,m.default)(this,(n=a.__proto__||Object.getPrototypeOf(a)).call.apply(n,[this].concat(e))),s.showAlertInfo=function(){_.Sweetalert.alert({closeBtn:!0,maskClosable:!0,content:"这个是具体内容",parentComponent:s})},p=t,(0,m.default)(s,p)}return(0,g.default)(a,n),(0,d.default)(a,[{key:"render",value:function(){return w.default.createElement(_.Button,{onClick:this.showAlertInfo},"带有关闭按钮")}}]),a}(w.default.Component);return w.default.createElement(n,null)},O=function(n){function a(){var n,t,s,p;(0,r.default)(this,a);for(var o=arguments.length,e=Array(o),c=0;c<o;c++)e[c]=arguments[c];return t=s=(0,m.default)(this,(n=a.__proto__||Object.getPrototypeOf(a)).call.apply(n,[this].concat(e))),s.state={showCode:!1},s.toggle=function(){s.setState({showCode:!s.state.showCode})},p=t,(0,m.default)(s,p)}return(0,g.default)(a,n),(0,d.default)(a,[{key:"render",value:function(){var n=this.state.showCode,a=this.props,t=a.title,s=a.src,o=a.children;return w.default.createElement("div",{className:"zandoc-react-demo"},w.default.createElement("div",{className:"zandoc-react-demo__preview"},o),w.default.createElement("div",{className:"zandoc-react-demo__bottom",onClick:this.toggle},w.default.createElement("div",{className:"zandoc-react-demo__title"},w.default.createElement("p",null,t||"")),w.default.createElement("i",{className:"zenticon zenticon-caret-up zandoc-react-demo__toggle "+(n?"zandoc-react-demo__toggle-on":"zandoc-react-demo__toggle-off")})),n&&w.default.createElement("pre",{className:"zandoc-react-demo__code"},w.default.createElement(p,{tag:"code",html:s,attributes:{className:"language-jsx"}})))}}]),a}(y.Component),z=function(n){function a(){return(0,r.default)(this,a),(0,m.default)(this,(a.__proto__||Object.getPrototypeOf(a)).apply(this,arguments))}return(0,g.default)(a,n),(0,d.default)(a,[{key:"componentDidMount",value:function(){var n=location.hash;if(n){var a=document.querySelector('a[href="'+n+'"]');a&&(0,v.default)(document.documentElement,0,c(a,-9))}}},{key:"render",value:function(){return w.default.createElement("div",{className:"zandoc-react-container",key:null},w.default.createElement(e,{style:""}),w.default.createElement(o,{html:'<h2 class="anchor-heading"><a href="#sweetalert-kuai-jie-dui-hua-kuang">¶</a><a href="javascript:void(0)" id="sweetalert-kuai-jie-dui-hua-kuang" class="anchor-point"></a>Sweetalert 快捷对话框</h2>\n<p>快速唤起 Dialog 组件</p>\n<h3 class="anchor-heading"><a href="#shi-yong-zhi-nan">¶</a><a href="javascript:void(0)" id="shi-yong-zhi-nan" class="anchor-point"></a>使用指南</h3>\n<ul>\n<li>组件不提供个性化选项,如有需要请使用 Dialog 组件。</li>\n</ul>\n<h3 class="anchor-heading"><a href="#dai-ma-yan-shi">¶</a><a href="javascript:void(0)" id="dai-ma-yan-shi" class="anchor-point"></a>代码演示</h3>'}),w.default.createElement(O,{title:"基础用法",id:"Demobasic",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> Sweetalert<span class="token punctuation">,</span> Button <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Wrapper</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>\n <span class="token function-variable function">showAlertInfo</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n Sweetalert<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n content<span class="token punctuation">:</span> <span class="token string">\'这个是具体内容\'</span><span class="token punctuation">,</span>\n parentComponent<span class="token punctuation">:</span> <span class="token keyword">this</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Button</span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>showAlertInfo<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>消息对话框<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Button</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n\nReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Wrapper</span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span>\n mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},w.default.createElement(b)),w.default.createElement(O,{title:"带有确认和取消按钮",id:"Demowithbuttons",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> Sweetalert<span class="token punctuation">,</span> Button<span class="token punctuation">,</span> Notify <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Wrapper</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>\n <span class="token function-variable function">onConfirm</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n Notify<span class="token punctuation">.</span><span class="token function">success</span><span class="token punctuation">(</span><span class="token string">\'我真的知道了\'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function-variable function">onCancel</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n Notify<span class="token punctuation">.</span><span class="token function">error</span><span class="token punctuation">(</span><span class="token string">\'我真的取消了\'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function-variable function">showAlertConfirm</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n Sweetalert<span class="token punctuation">.</span><span class="token function">confirm</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n content<span class="token punctuation">:</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>这个是内容<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span><span class="token punctuation">,</span>\n onConfirm<span class="token punctuation">:</span> <span class="token keyword">this</span><span class="token punctuation">.</span>onConfirm<span class="token punctuation">,</span>\n onCancel<span class="token punctuation">:</span> <span class="token keyword">this</span><span class="token punctuation">.</span>onCancel<span class="token punctuation">,</span>\n parentComponent<span class="token punctuation">:</span> <span class="token keyword">this</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Button</span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>showAlertConfirm<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>消息对话框<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Button</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n\nReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Wrapper</span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span>\n mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},w.default.createElement(E)),w.default.createElement(O,{title:"自动关闭",id:"Democlosedexternal",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> Sweetalert<span class="token punctuation">,</span> Button <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Wrapper</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>\n <span class="token function-variable function">autoCloseConfirm</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n <span class="token keyword">const</span> close <span class="token operator">=</span> Sweetalert<span class="token punctuation">.</span><span class="token function">confirm</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n content<span class="token punctuation">:</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>一秒后自动关闭<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span><span class="token punctuation">,</span>\n parentComponent<span class="token punctuation">:</span> <span class="token keyword">this</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n\n <span class="token function">setTimeout</span><span class="token punctuation">(</span>close<span class="token punctuation">,</span> <span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Button</span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>autoCloseConfirm<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>自动关闭对话框<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Button</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n\nReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Wrapper</span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span>\n mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},w.default.createElement(B)),w.default.createElement(O,{title:"回调返回 Promise",id:"Demoreturnpromise",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> Sweetalert<span class="token punctuation">,</span> Button <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Wrapper</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>\n <span class="token function-variable function">promiseConfirm</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n Sweetalert<span class="token punctuation">.</span><span class="token function">confirm</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n content<span class="token punctuation">:</span> <span class="token string">\'点击确定后三秒自动关闭\'</span><span class="token punctuation">,</span>\n title<span class="token punctuation">:</span> <span class="token string">\'onConfirm返回Promise\'</span><span class="token punctuation">,</span>\n onConfirm<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span>resolve<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n <span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n <span class="token function">resolve</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">3000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span>\n parentComponent<span class="token punctuation">:</span> <span class="token keyword">this</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Button</span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>promiseConfirm<span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token function">自动关闭对话框</span><span class="token punctuation">(</span>Promise<span class="token punctuation">)</span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Button</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n\nReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Wrapper</span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span>\n mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},w.default.createElement(A)),w.default.createElement(O,{title:"标题旁带有 icon 的 Dialog",id:"Demowithicon",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> Sweetalert<span class="token punctuation">,</span> Button <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Wrapper</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>\n <span class="token function-variable function">showAlertInfo</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n Sweetalert<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n type<span class="token punctuation">:</span> <span class="token string">\'info\'</span><span class="token punctuation">,</span>\n content<span class="token punctuation">:</span> <span class="token string">\'这个是具体内容\'</span><span class="token punctuation">,</span>\n title<span class="token punctuation">:</span> <span class="token string">\'这是一个消息标题\'</span><span class="token punctuation">,</span>\n parentComponent<span class="token punctuation">:</span> <span class="token keyword">this</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Button</span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>showAlertInfo<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>含有图标消息对话框<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Button</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n\nReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Wrapper</span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span>\n mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},w.default.createElement(N)),w.default.createElement(O,{title:"支持设置 Dialog 中的 button 类型",id:"Demobuttontype",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> Sweetalert<span class="token punctuation">,</span> Button <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Wrapper</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>\n <span class="token function-variable function">showAlertConfirm</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n Sweetalert<span class="token punctuation">.</span><span class="token function">confirm</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n confirmType<span class="token punctuation">:</span> <span class="token string">\'danger\'</span><span class="token punctuation">,</span>\n confirmText<span class="token punctuation">:</span> <span class="token string">\'删除\'</span><span class="token punctuation">,</span>\n cancelText<span class="token punctuation">:</span> <span class="token string">\'取消\'</span><span class="token punctuation">,</span>\n content<span class="token punctuation">:</span> <span class="token string">\'确认删除吗?\'</span><span class="token punctuation">,</span>\n title<span class="token punctuation">:</span> <span class="token string">\'请确认\'</span><span class="token punctuation">,</span>\n parentComponent<span class="token punctuation">:</span> <span class="token keyword">this</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Button</span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>showAlertConfirm<span class="token punctuation">}</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>danger<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>删除<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Button</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n\nReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Wrapper</span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span>\n mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},w.default.createElement(S)),w.default.createElement(O,{title:"带有右上角的关闭按钮",id:"Demowithclosebtn",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> Sweetalert<span class="token punctuation">,</span> Button <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">\'zent\'</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Wrapper</span> <span class="token keyword">extends</span> <span class="token class-name">React<span class="token punctuation">.</span>Component</span> <span class="token punctuation">{</span>\n <span class="token function-variable function">showAlertInfo</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n Sweetalert<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n closeBtn<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>\n maskClosable<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>\n content<span class="token punctuation">:</span> <span class="token string">\'这个是具体内容\'</span><span class="token punctuation">,</span>\n parentComponent<span class="token punctuation">:</span> <span class="token keyword">this</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function">render</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>\n <span class="token keyword">return</span> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Button</span> <span class="token attr-name">onClick</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span><span class="token keyword">this</span><span class="token punctuation">.</span>showAlertInfo<span class="token punctuation">}</span></span><span class="token punctuation">></span></span>带有关闭按钮<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Button</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n<span class="token punctuation">}</span>\n\nReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Wrapper</span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span>\n mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},w.default.createElement(j)),w.default.createElement(o,{html:"<h3 class=\"anchor-heading\"><a href=\"#api\">¶</a><a href=\"javascript:void(0)\" id=\"api\" class=\"anchor-point\"></a>API</h3>\n<h4 class=\"anchor-heading\"><a href=\"#alert\">¶</a><a href=\"javascript:void(0)\" id=\"alert\" class=\"anchor-point\"></a>alert</h4>\n<table class=\"table\">\n<thead>\n<tr>\n<th>参数</th>\n<th>说明</th>\n<th>类型</th>\n<th>默认值</th>\n<th>备选值</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>content</td>\n<td>弹窗中的内容</td>\n<td>node</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>type</td>\n<td>弹窗的类型, 设置会在title左边显示一个小图标, 不传不会显示图标</td>\n<td>string</td>\n<td>-</td>\n<td><code>'info'</code>\n, \n<code>'success'</code>\n, \n<code>'error'</code>\n, \n<code>'warning'</code></td>\n</tr>\n<tr>\n<td>title</td>\n<td>弹窗的标题</td>\n<td>node</td>\n<td><code>''</code></td>\n<td></td>\n</tr>\n<tr>\n<td>onConfirm</td>\n<td>确定操作回调函数</td>\n<td>func</td>\n<td><code>noop</code></td>\n<td></td>\n</tr>\n<tr>\n<td>confirmText</td>\n<td>确定按钮文案</td>\n<td>string</td>\n<td><code>'我知道了'</code></td>\n<td></td>\n</tr>\n<tr>\n<td>confirmType</td>\n<td>确定按钮的类型</td>\n<td>string</td>\n<td><code>'primary'</code></td>\n<td><code>'default'</code>\n、\n<code>'primary'</code>\n、\n<code>'danger'</code>\n、\n<code>'success'</code></td>\n</tr>\n<tr>\n<td>closeBtn</td>\n<td>是否显示右上角关闭按钮</td>\n<td>bool</td>\n<td><code>false</code></td>\n<td></td>\n</tr>\n<tr>\n<td>maskClosable</td>\n<td>点击遮罩是否可以关闭</td>\n<td>bool</td>\n<td><code>false</code></td>\n<td></td>\n</tr>\n<tr>\n<td>parentComponent</td>\n<td>父级组件实例,i18n 需要通过这个传递 context</td>\n<td>ReactInstance</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>className</td>\n<td>额外的className</td>\n<td>string</td>\n<td><code>''</code></td>\n<td></td>\n</tr>\n<tr>\n<td>prefix</td>\n<td>默认className的前缀</td>\n<td>string</td>\n<td><code>'zent'</code></td>\n<td></td>\n</tr>\n</tbody>\n</table>\n<h4 class=\"anchor-heading\"><a href=\"#confirm\">¶</a><a href=\"javascript:void(0)\" id=\"confirm\" class=\"anchor-point\"></a>confirm</h4>\n<table class=\"table\">\n<thead>\n<tr>\n<th>参数</th>\n<th>说明</th>\n<th>类型</th>\n<th>默认值</th>\n<th>备选值</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>content</td>\n<td>弹窗中的内容</td>\n<td>node</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>type</td>\n<td>弹窗的类型, 设置会在title左边显示一个小图标, 不传不会显示图标</td>\n<td>string</td>\n<td>-</td>\n<td><code>'info'</code>\n, \n<code>'success'</code>\n, \n<code>'error'</code>\n, \n<code>'warning'</code></td>\n</tr>\n<tr>\n<td>title</td>\n<td>弹窗的标题</td>\n<td>node</td>\n<td><code>''</code></td>\n<td></td>\n</tr>\n<tr>\n<td>onCancel</td>\n<td>取消操作回调函数</td>\n<td>func</td>\n<td><code>noop</code></td>\n<td></td>\n</tr>\n<tr>\n<td>onConfirm</td>\n<td>确定操作回调函数</td>\n<td>func</td>\n<td><code>noop</code></td>\n<td></td>\n</tr>\n<tr>\n<td>cancelText</td>\n<td>取消按钮文案</td>\n<td>string</td>\n<td><code>'取消'</code></td>\n<td></td>\n</tr>\n<tr>\n<td>confirmText</td>\n<td>确定按钮文案</td>\n<td>string</td>\n<td><code>'确定'</code></td>\n<td></td>\n</tr>\n<tr>\n<td>confirmType</td>\n<td>确定按钮的类型</td>\n<td>string</td>\n<td><code>'primary'</code></td>\n<td><code>'default'</code>\n、\n<code>'primary'</code>\n、\n<code>'danger'</code>\n、\n<code>'success'</code></td>\n</tr>\n<tr>\n<td>closeBtn</td>\n<td>是否显示右上角关闭按钮</td>\n<td>bool</td>\n<td><code>false</code></td>\n<td></td>\n</tr>\n<tr>\n<td>maskClosable</td>\n<td>点击遮罩是否可以关闭</td>\n<td>bool</td>\n<td><code>false</code></td>\n<td></td>\n</tr>\n<tr>\n<td>className</td>\n<td>额外的className</td>\n<td>string</td>\n<td><code>''</code></td>\n<td></td>\n</tr>\n<tr>\n<td>prefix</td>\n<td>默认className的前缀</td>\n<td>string</td>\n<td><code>'zent'</code></td>\n<td></td>\n</tr>\n</tbody>\n</table>\n<ul>\n<li><code>Sweetalert.alert</code> 和 <code>Sweetalert.confirm</code> 的返回值是可以用来手动关闭对话框的函数。</li>\n<li>如果 <code>onConfirm</code> 的返回值是 <code>Promise</code>, 对应的按钮会在 <code>Promise</code> pending 时保持在 loading 状态;如果 <code>Promise</code> reject,对话框不会关闭,如果 <code>Promise</code> resolve 对话框关闭。</li>\n<li>如果 <code>onConfirm</code> 没有参数并且返回值是 <code>false</code> 对话框不会关闭。</li>\n<li>如果 <code>onConfirm</code> 有一个参数的话,需要手动调用 <code>close</code> 这个参数来关闭对话框。</li>\n</ul>"}))}}]),a}(y.Component);a.default=z}});