-
Notifications
You must be signed in to change notification settings - Fork 0
/
127-bc4eac5649ec72ccd951.js
1 lines (1 loc) · 46.6 KB
/
127-bc4eac5649ec72ccd951.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[127],{656:function(n,a,s){"use strict";s.r(a),s.d(a,"default",function(){return P});var t=s(580),p=s.n(t),e=s(581),o=s.n(e),c=s(32),u=s.n(c),l=s(28),i=s.n(l),k=s(23),r=s.n(k),d=s(24),m=s.n(d),g=s(25),h=s.n(g),w=s(26),v=s.n(w),f=s(27),y=s.n(f),b=s(0),x=s.n(b),E=s(111),N=s(82),S=function(){var n=[1,2,3,4,5],a=function(a){function s(){return r()(this,s),h()(this,v()(s).apply(this,arguments))}return y()(s,a),m()(s,[{key:"render",value:function(){return x.a.createElement("div",{className:"swiper-demo-container"},x.a.createElement(N.wb,{className:"swiper-demo-simple"},n.map(function(n,a){return x.a.createElement("div",{className:"swiper-demo-simple-h",key:a},n)})),x.a.createElement(N.wb,{className:"swiper-demo-simple",dotsColor:"#31A896",dotsSize:"small"},n.map(function(n,a){return x.a.createElement("div",{className:"swiper-demo-simple-h",key:a},n)})))}}]),s}(x.a.Component);return x.a.createElement(a,null)},C=function(){var n=[1,2,3,4,5],a=function(a){function s(){var n,a;r()(this,s);for(var t=arguments.length,p=new Array(t),e=0;e<t;e++)p[e]=arguments[e];return a=h()(this,(n=v()(s)).call.apply(n,[this].concat(p))),i()(u()(a),"state",{current:null,prev:null}),i()(u()(a),"handleChange",function(n,s){a.setState({current:n,prev:s})}),a}return y()(s,a),m()(s,[{key:"render",value:function(){var a=this.state,s=a.current,t=a.prev;return x.a.createElement("div",null,x.a.createElement(N.wb,{className:"swiper-demo-simple",dotsColor:"red",dotsSize:"small",arrows:!0,autoplay:!0,onChange:this.handleChange},n.map(function(n,a){return x.a.createElement("div",{className:"swiper-demo-simple-h",key:a},n)})),"number"==typeof s&&"number"==typeof t&&x.a.createElement("div",{className:"swiper-demo-simple-text"},"从 ",t+1," 到 ",s+1))}}]),s}(x.a.Component);return x.a.createElement(a,null)},z=function(){var n=[1,2,3,4,5],a=function(a){function s(){var n,a;r()(this,s);for(var t=arguments.length,p=new Array(t),e=0;e<t;e++)p[e]=arguments[e];return a=h()(this,(n=v()(s)).call.apply(n,[this].concat(p))),i()(u()(a),"go",function(n){a.swiper.swipeTo(n)}),i()(u()(a),"prev",function(){a.swiper.prev()}),i()(u()(a),"next",function(){a.swiper.next()}),a}return y()(s,a),m()(s,[{key:"render",value:function(){var a=this;return x.a.createElement("div",{className:"swiper-demo-container no-flex"},x.a.createElement(N.wb,{ref:function(n){return a.swiper=n},className:"swiper-demo-simple"},n.map(function(n,a){return x.a.createElement("div",{className:"swiper-demo-simple-h",key:a},n)})),x.a.createElement("div",{className:"swiper-demo-btn-group"},n.map(function(n,s){return x.a.createElement(N.i,{key:s,type:"primary",onClick:function(){return a.go(s)}},n)}),x.a.createElement(N.i,{type:"primary",outline:!0,onClick:function(){return a.prev()}},"prev"),x.a.createElement(N.i,{type:"primary",outline:!0,onClick:function(){return a.next()}},"next")))}}]),s}(x.a.Component);return x.a.createElement(a,null)},j=function(){var n=function(n){function a(){var n,s;r()(this,a);for(var t=arguments.length,p=new Array(t),e=0;e<t;e++)p[e]=arguments[e];return s=h()(this,(n=v()(a)).call.apply(n,[this].concat(p))),i()(u()(s),"state",{pages:[1,2,3,4,5]}),i()(u()(s),"handleAddPage",function(){var n=s.state.pages,a=n[n.length-1];console.log(a),s.setState({pages:[].concat(o()(n),[a+1])})}),i()(u()(s),"handleRemovePage",function(){var n=s.state.pages,a=n.filter(function(a,s){return s!==n.length-1});s.setState({pages:a})}),s}return y()(a,n),m()(a,[{key:"render",value:function(){var n=this.state.pages;return x.a.createElement("div",null,x.a.createElement(N.wb,{className:"swiper-demo-simple",dotsColor:"#fc0",dotsSize:"small",arrows:!0,autoplay:!0},n.map(function(n,a){return x.a.createElement("div",{className:"swiper-demo-simple-h",key:a},n)})),x.a.createElement("div",{style:{marginTop:"20px"}},x.a.createElement(N.i,{type:"primary",onClick:this.handleAddPage},"增加"),x.a.createElement(N.i,{type:"primary",outline:!0,onClick:this.handleRemovePage},"移除")))}}]),a}(x.a.Component);return x.a.createElement(n,null)};function _(n){return x.a.createElement(n.tag,p()({},n.attributes,{dangerouslySetInnerHTML:{__html:n.html}}))}function A(n){return x.a.createElement(_,{tag:"section",html:n.html,attributes:{className:"zandoc-react-markdown"}})}function B(n){return x.a.createElement(_,{tag:"style",html:n.style})}var R=function(n){function a(){var n,s;r()(this,a);for(var t=arguments.length,p=new Array(t),e=0;e<t;e++)p[e]=arguments[e];return s=h()(this,(n=v()(a)).call.apply(n,[this].concat(p))),i()(u()(s),"state",{showCode:!1}),i()(u()(s),"toggle",function(){s.setState({showCode:!s.state.showCode})}),s}return y()(a,n),m()(a,[{key:"render",value:function(){var n=this.state.showCode,a=this.props,s=a.title,t=a.src,p=a.children;return x.a.createElement("div",{className:"zandoc-react-demo"},x.a.createElement("div",{className:"zandoc-react-demo__preview"},p),x.a.createElement("div",{className:"zandoc-react-demo__bottom",onClick:this.toggle},x.a.createElement("div",{className:"zandoc-react-demo__title"},x.a.createElement("p",null,s||"")),x.a.createElement("i",{className:"zenticon zenticon-caret-up zandoc-react-demo__toggle ".concat(n?"zandoc-react-demo__toggle-on":"zandoc-react-demo__toggle-off")})),n&&x.a.createElement("pre",{className:"zandoc-react-demo__code"},x.a.createElement(_,{tag:"code",html:t,attributes:{className:"language-jsx"}})))}}]),a}(b.Component),P=function(n){function a(){return r()(this,a),h()(this,v()(a).apply(this,arguments))}return y()(a,n),m()(a,[{key:"componentDidMount",value:function(){var n=location.hash;if(n){var a=document.querySelector('a[href="'.concat(n,'"]'));a&&Object(E.a)(document.documentElement,0,function n(a,s){for(;a;)return a.offsetTop&&"static"!==getComputedStyle(a).position&&(s+=a.offsetTop),n(a.parentNode,s);return s}(a,-9))}}},{key:"render",value:function(){return x.a.createElement("div",{className:"zandoc-react-container",key:null},x.a.createElement(B,{style:".swiper-demo-container {\n\tdisplay: flex;\n}\n.swiper-demo-simple {\n\theight: 150px;\n\twidth: 300px;\n\tbackground: #FAFAFA;\n\tmargin-right: 10px;\n}\n.swiper-demo-simple-h {\n\ttext-align: center;\n\tfont-size: 18px;\n\tline-height: 150px;\n}\n.swiper-demo-simple-text {\n\tmargin-top: 10px;\n}\n.swiper-demo-btn-group {\n\tmargin-top: 20px;\n}\n.no-flex {\n\tdisplay: block !important;\n}"}),x.a.createElement(A,{html:'<h2 class="anchor-heading"><a href="#swiper-lun-bo">¶</a><a href="javascript:void(0)" id="swiper-lun-bo" class="anchor-point"></a>Swiper 轮播</h2>\n<p>Swiper 主要用于对一组平级内容进行轮播展示</p>\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>'}),x.a.createElement(R,{title:"基础用法",id:"Demobasic",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> Swiper <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">const</span> pages <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">]</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Simple</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">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 punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>swiper-demo-container<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Swiper</span>\n <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>swiper-demo-simple<span class="token punctuation">"</span></span>\n <span class="token punctuation">></span></span>\n <span class="token punctuation">{</span>\n pages<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item<span class="token punctuation">,</span> index<span class="token punctuation">)</span> <span class="token operator">=></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>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>swiper-demo-simple-h<span class="token punctuation">"</span></span> <span class="token attr-name">key</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span>index<span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token punctuation">{</span>item<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span>\n <span class="token punctuation">}</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Swiper</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Swiper</span>\n <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>swiper-demo-simple<span class="token punctuation">"</span></span>\n <span class="token attr-name">dotsColor</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>#31A896<span class="token punctuation">"</span></span>\n <span class="token attr-name">dotsSize</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>small<span class="token punctuation">"</span></span>\n <span class="token punctuation">></span></span>\n <span class="token punctuation">{</span>\n pages<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item<span class="token punctuation">,</span> index<span class="token punctuation">)</span> <span class="token operator">=></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>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>swiper-demo-simple-h<span class="token punctuation">"</span></span> <span class="token attr-name">key</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span>index<span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token punctuation">{</span>item<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span>\n <span class="token punctuation">}</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Swiper</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n\n <span class="token punctuation">)</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>Simple</span> <span class="token punctuation">/></span></span>\n <span class="token punctuation">,</span> mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},x.a.createElement(S)),x.a.createElement(R,{title:"带左右箭头, 自动切换",id:"Demoarrow",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> Swiper <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">const</span> pages <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">]</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Simple</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\n state <span class="token operator">=</span> <span class="token punctuation">{</span>\n current<span class="token punctuation">:</span> <span class="token keyword">null</span><span class="token punctuation">,</span>\n prev<span class="token punctuation">:</span> <span class="token keyword">null</span>\n <span class="token punctuation">}</span>\n\n <span class="token function-variable function">handleChange</span> <span class="token operator">=</span> <span class="token punctuation">(</span>current<span class="token punctuation">,</span> prev<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span> current<span class="token punctuation">,</span> prev <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">const</span> <span class="token punctuation">{</span> current<span class="token punctuation">,</span> prev <span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">;</span>\n <span class="token keyword">return</span> <span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Swiper</span>\n <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>swiper-demo-simple<span class="token punctuation">"</span></span>\n <span class="token attr-name">dotsColor</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>red<span class="token punctuation">"</span></span>\n <span class="token attr-name">dotsSize</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>small<span class="token punctuation">"</span></span>\n <span class="token attr-name">arrows</span>\n <span class="token attr-name">autoplay</span>\n <span class="token attr-name">onChange</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>handleChange<span class="token punctuation">}</span></span>\n <span class="token punctuation">></span></span>\n <span class="token punctuation">{</span>\n pages<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item<span class="token punctuation">,</span> index<span class="token punctuation">)</span> <span class="token operator">=></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>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>swiper-demo-simple-h<span class="token punctuation">"</span></span> <span class="token attr-name">key</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span>index<span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token punctuation">{</span>item<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span>\n <span class="token punctuation">}</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Swiper</span><span class="token punctuation">></span></span>\n <span class="token punctuation">{</span>\n <span class="token keyword">typeof</span> current <span class="token operator">===</span> <span class="token string">\'number\'</span> <span class="token operator">&&</span> <span class="token keyword">typeof</span> prev <span class="token operator">===</span> <span class="token string">\'number\'</span> <span class="token operator">&&</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>swiper-demo-simple-text<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>从 <span class="token punctuation">{</span>prev <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">}</span> 到 <span class="token punctuation">{</span>current <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token punctuation">}</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token punctuation">)</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>Simple</span> <span class="token punctuation">/></span></span>\n <span class="token punctuation">,</span> mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},x.a.createElement(C)),x.a.createElement(R,{title:"外部方法控制轮播",id:"Demomethod",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> Swiper<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">const</span> pages <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">]</span><span class="token punctuation">;</span>\n\n<span class="token keyword">class</span> <span class="token class-name">Simple</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\n <span class="token function-variable function">go</span> <span class="token operator">=</span> <span class="token punctuation">(</span>index<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n <span class="token keyword">this</span><span class="token punctuation">.</span>swiper<span class="token punctuation">.</span><span class="token function">swipeTo</span><span class="token punctuation">(</span>index<span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span>\n\n <span class="token function-variable function">prev</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">this</span><span class="token punctuation">.</span>swiper<span class="token punctuation">.</span><span class="token function">prev</span><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-variable function">next</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">this</span><span class="token punctuation">.</span>swiper<span class="token punctuation">.</span><span class="token function">next</span><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 punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>swiper-demo-container no-flex<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Swiper</span>\n <span class="token attr-name">ref</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span><span class="token punctuation">(</span>swiper<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token keyword">this</span><span class="token punctuation">.</span>swiper <span class="token operator">=</span> swiper<span class="token punctuation">}</span></span>\n <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>swiper-demo-simple<span class="token punctuation">"</span></span>\n <span class="token punctuation">></span></span>\n <span class="token punctuation">{</span>\n pages<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item<span class="token punctuation">,</span> index<span class="token punctuation">)</span> <span class="token operator">=></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>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>swiper-demo-simple-h<span class="token punctuation">"</span></span> <span class="token attr-name">key</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span>index<span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token punctuation">{</span>item<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span>\n <span class="token punctuation">}</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Swiper</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>swiper-demo-btn-group<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>\n <span class="token punctuation">{</span>\n pages<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item<span class="token punctuation">,</span> index<span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span>\n <span class="token keyword">return</span> <span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Button</span>\n <span class="token attr-name">key</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span>index<span class="token punctuation">}</span></span>\n <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</span></span>\n <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 punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">go</span><span class="token punctuation">(</span>index<span class="token punctuation">)</span><span class="token punctuation">}</span></span>\n <span class="token punctuation">></span></span>\n <span class="token punctuation">{</span>item<span class="token punctuation">}</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Button</span><span class="token punctuation">></span></span>\n <span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span>\n <span class="token punctuation">}</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Button</span>\n <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</span></span>\n <span class="token attr-name">outline</span>\n <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 punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">prev</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>\n prev\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Button</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Button</span>\n <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</span></span>\n <span class="token attr-name">outline</span>\n <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 punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">}</span></span><span class="token punctuation">></span></span>\n next\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Button</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n\n <span class="token punctuation">)</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>Simple</span> <span class="token punctuation">/></span></span>\n <span class="token punctuation">,</span> mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},x.a.createElement(z)),x.a.createElement(R,{title:"动态增减子元素",id:"Demodynamicaddchild",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> Swiper<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">Simple</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\n state <span class="token operator">=</span> <span class="token punctuation">{</span>\n pages<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">]</span>\n <span class="token punctuation">}</span>\n\n <span class="token function-variable function">handleAddPage</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> <span class="token punctuation">{</span> pages <span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">;</span>\n <span class="token keyword">const</span> lastItem <span class="token operator">=</span> pages<span class="token punctuation">[</span>pages<span class="token punctuation">.</span>length <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">;</span>\n console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>lastItem<span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n pages<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token operator">...</span>pages<span class="token punctuation">,</span> lastItem <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">]</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-variable function">handleRemovePage</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> <span class="token punctuation">{</span> pages <span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">;</span>\n <span class="token keyword">const</span> newPages <span class="token operator">=</span> pages<span class="token punctuation">.</span><span class="token function">filter</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item<span class="token punctuation">,</span> index<span class="token punctuation">)</span> <span class="token operator">=></span> index <span class="token operator">!==</span> pages<span class="token punctuation">.</span>length <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">setState</span><span class="token punctuation">(</span><span class="token punctuation">{</span>\n pages<span class="token punctuation">:</span> newPages\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">const</span> <span class="token punctuation">{</span> pages <span class="token punctuation">}</span> <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span>state<span class="token punctuation">;</span>\n <span class="token keyword">return</span> <span class="token punctuation">(</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Swiper</span>\n <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>swiper-demo-simple<span class="token punctuation">"</span></span>\n <span class="token attr-name">dotsColor</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>#fc0<span class="token punctuation">"</span></span>\n <span class="token attr-name">dotsSize</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>small<span class="token punctuation">"</span></span>\n <span class="token attr-name">arrows</span>\n <span class="token attr-name">autoplay</span>\n <span class="token punctuation">></span></span>\n <span class="token punctuation">{</span>\n pages<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span><span class="token punctuation">(</span>item<span class="token punctuation">,</span> index<span class="token punctuation">)</span> <span class="token operator">=></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>div</span> <span class="token attr-name">className</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>swiper-demo-simple-h<span class="token punctuation">"</span></span> <span class="token attr-name">key</span><span class="token script language-javascript"><span class="token punctuation">=</span><span class="token punctuation">{</span>index<span class="token punctuation">}</span></span><span class="token punctuation">></span></span><span class="token punctuation">{</span>item<span class="token punctuation">}</span><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span><span class="token punctuation">;</span>\n <span class="token punctuation">}</span><span class="token punctuation">)</span>\n <span class="token punctuation">}</span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>Swiper</span><span class="token punctuation">></span></span>\n <span class="token operator"><</span>div style<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span> marginTop<span class="token punctuation">:</span> <span class="token string">\'20px\'</span> <span class="token punctuation">}</span><span class="token punctuation">}</span><span class="token operator">></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Button</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</span></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>handleAddPage<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>\n <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Button</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>primary<span class="token punctuation">"</span></span> <span class="token attr-name">outline</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>handleRemovePage<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>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>\n <span class="token punctuation">)</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>Simple</span> <span class="token punctuation">/></span></span>\n <span class="token punctuation">,</span> mountNode\n<span class="token punctuation">)</span><span class="token punctuation">;</span>'},x.a.createElement(j)),x.a.createElement(A,{html:"<h3 class=\"anchor-heading\"><a href=\"#api\">¶</a><a href=\"javascript:void(0)\" id=\"api\" class=\"anchor-point\"></a>API</h3>\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>transitionDuration</td>\n<td>切换动画持续时间(ms)</td>\n<td>number</td>\n<td><code>300</code></td>\n<td></td>\n</tr>\n<tr>\n<td>autoplay</td>\n<td>是否自动切换</td>\n<td>bool</td>\n<td><code>false</code></td>\n<td><code>false</code>\n, \n<code>true</code></td>\n</tr>\n<tr>\n<td>autoplayInterval</td>\n<td>自动切换间隔时间(ms)</td>\n<td>number</td>\n<td><code>3000</code></td>\n<td></td>\n</tr>\n<tr>\n<td>dots</td>\n<td>是否显示下方翻页按钮</td>\n<td>bool</td>\n<td><code>true</code></td>\n<td><code>true</code>\n, \n<code>false</code></td>\n</tr>\n<tr>\n<td>dotsColor</td>\n<td>下方翻页按钮颜色</td>\n<td>string</td>\n<td><code>'black'</code></td>\n<td><code>'blue'</code>\n, \n<code>'red'</code>\n, \n<code>'green'</code>\n, \n<code>自定义css颜色值</code></td>\n</tr>\n<tr>\n<td>dotsSize</td>\n<td>下方翻页按钮大小</td>\n<td>string</td>\n<td><code>'normal'</code></td>\n<td><code>'small'</code>\n, \n<code>'large'</code></td>\n</tr>\n<tr>\n<td>arrows</td>\n<td>是否显示两侧翻页按钮</td>\n<td>bool</td>\n<td><code>false</code></td>\n<td><code>true</code>\n, \n<code>false</code></td>\n</tr>\n<tr>\n<td>arrowsType</td>\n<td>两侧箭头颜色</td>\n<td>string</td>\n<td><code>'dark'</code></td>\n<td><code>'dark'</code>\n, \n<code>'light'</code></td>\n</tr>\n<tr>\n<td>onChange</td>\n<td>切换时回调函数</td>\n<td>(current: number, prev: number): void</td>\n<td><code>noop</code></td>\n<td></td>\n</tr>\n<tr>\n<td>className</td>\n<td>自定义额外类名</td>\n<td>string</td>\n<td><code>''</code></td>\n<td></td>\n</tr>\n<tr>\n<td>prefix</td>\n<td>自定义前缀</td>\n<td>string</td>\n<td><code>'zent'</code></td>\n<td></td>\n</tr>\n</tbody>\n</table>\n<h3 class=\"anchor-heading\"><a href=\"#shi-li-fang-fa\">¶</a><a href=\"javascript:void(0)\" id=\"shi-li-fang-fa\" class=\"anchor-point\"></a>实例方法</h3>\n<table class=\"table\">\n<thead>\n<tr>\n<th>方法名</th>\n<th>说明</th>\n<th>参数名</th>\n<th>参数描述</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>swipeTo</td>\n<td>手动切换轮播图</td>\n<td>index</td>\n<td>需要切换的轮播图索引,从0开始</td>\n</tr>\n<tr>\n<td>prev</td>\n<td>切换至上一张轮播图</td>\n<td></td>\n<td></td>\n</tr>\n<tr>\n<td>next</td>\n<td>切换至下一张轮播图</td>\n<td></td>\n<td></td>\n</tr>\n</tbody>\n</table>"}))}}]),a}(b.Component)}}]);