-
Notifications
You must be signed in to change notification settings - Fork 0
/
33-a28f22da2d828c0b81f9.js
1 lines (1 loc) · 34 KB
/
33-a28f22da2d828c0b81f9.js
1
webpackJsonp([33],{1583:function(n,s,a){"use strict";function t(n){return n&&n.__esModule?n:{default:n}}function p(n){return b.default.createElement(n.tag,(0,l.default)({},n.attributes,{dangerouslySetInnerHTML:{__html:n.html}}))}function o(n){return b.default.createElement(p,{tag:"section",html:n.html,attributes:{className:"zandoc-react-markdown"}})}function c(n){return b.default.createElement(p,{tag:"style",html:n.style})}function e(n,s){for(;n;)return n.offsetTop&&"static"!==getComputedStyle(n).position&&(s+=n.offsetTop),e(n.parentNode,s);return s}Object.defineProperty(s,"__esModule",{value:!0});var u=a(7),l=t(u),i=a(1),k=t(i),d=a(4),r=t(d),m=a(2),f=t(m),g=a(3),h=t(g),v=a(0),b=t(v),_=a(232),y=t(_),x=a(359),S=function(){var n=[{id:10740,text:"颜色"},{id:40732,text:"尺寸"}],s=[{id:3,text:"蓝色"},{id:10,text:"红色"},{id:30,text:"土豪金"},{id:137,text:"黑色"},{id:138,text:"灰色"}],a=function(a){function t(){return(0,k.default)(this,t),(0,f.default)(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return(0,h.default)(t,a),(0,r.default)(t,[{key:"fetchSKUTree",value:function(){return new Promise(function(s){s(n)})}},{key:"fetchSKU",value:function(){return new Promise(function(n){n(s)})}},{key:"render",value:function(){return b.default.createElement(x.SKU,{showSKULabel:!0,onFetchGroup:this.fetchSKUTree,onFetchSKU:this.fetchSKU})}}]),t}(v.Component);return b.default.createElement(a,null)},w=function(){x.SKU.flatten;return b.default.createElement("p",{style:{fontSize:14,color:"#333"}},"请看代码")},K=function(){x.SKU.isSame;return b.default.createElement("p",{style:{fontSize:14,color:"#333"}},"请看代码")},U=function(n){function s(){var n,a,t,p;(0,k.default)(this,s);for(var o=arguments.length,c=Array(o),e=0;e<o;e++)c[e]=arguments[e];return a=t=(0,f.default)(this,(n=s.__proto__||Object.getPrototypeOf(s)).call.apply(n,[this].concat(c))),t.state={showCode:!1},t.toggle=function(){t.setState({showCode:!t.state.showCode})},p=a,(0,f.default)(t,p)}return(0,h.default)(s,n),(0,r.default)(s,[{key:"render",value:function(){var n=this.state.showCode,s=this.props,a=s.title,t=s.src,o=s.children;return b.default.createElement("div",{className:"zandoc-react-demo"},b.default.createElement("div",{className:"zandoc-react-demo__preview"},o),b.default.createElement("div",{className:"zandoc-react-demo__bottom",onClick:this.toggle},b.default.createElement("div",{className:"zandoc-react-demo__title"},b.default.createElement("p",null,a||"")),b.default.createElement("i",{className:"zenticon zenticon-caret-up zandoc-react-demo__toggle "+(n?"zandoc-react-demo__toggle-on":"zandoc-react-demo__toggle-off")})),n&&b.default.createElement("pre",{className:"zandoc-react-demo__code"},b.default.createElement(p,{tag:"code",html:t,attributes:{className:"language-jsx"}})))}}]),s}(v.Component),E=function(n){function s(){return(0,k.default)(this,s),(0,f.default)(this,(s.__proto__||Object.getPrototypeOf(s)).apply(this,arguments))}return(0,h.default)(s,n),(0,r.default)(s,[{key:"componentDidMount",value:function(){var n=location.hash;if(n){var s=document.querySelector('a[href="'+n+'"]');s&&(0,y.default)(document.documentElement,0,e(s,-9))}}},{key:"render",value:function(){return b.default.createElement("div",{className:"zandoc-react-container",key:null},b.default.createElement(c,{style:""}),b.default.createElement(o,{html:'<h2 class="anchor-heading"><a href="#sku-gui-ge-xuan-ze-qi">¶</a><a href="javascript:void(0)" id="sku-gui-ge-xuan-ze-qi" class="anchor-point"></a>SKU 规格选择器</h2>\n<p>这是一个规格选择</p>\n<h3 class="anchor-heading"><a href="#shi-yong-chang-jing">¶</a><a href="javascript:void(0)" id="shi-yong-chang-jing" class="anchor-point"></a>使用场景</h3>\n<p>创建有多种规格的商品、服务的编辑页面</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>'}),b.default.createElement(U,{title:"基础用法",id:"Demobasic",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> SKU <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> skuTree <span class="token operator">=</span> <span class="token punctuation">[</span>\n <span class="token punctuation">{</span>\n id<span class="token punctuation">:</span> <span class="token number">10740</span><span class="token punctuation">,</span>\n text<span class="token punctuation">:</span> <span class="token string">\'颜色\'</span><span class="token punctuation">,</span>\n <span class="token punctuation">}</span><span class="token punctuation">,</span>\n <span class="token punctuation">{</span>\n id<span class="token punctuation">:</span> <span class="token number">40732</span><span class="token punctuation">,</span>\n text<span class="token punctuation">:</span> <span class="token string">\'尺寸\'</span><span class="token punctuation">,</span>\n <span class="token punctuation">}</span><span class="token punctuation">,</span>\n<span class="token punctuation">]</span><span class="token punctuation">;</span>\n\n<span class="token keyword">const</span> sku <span class="token operator">=</span> <span class="token punctuation">[</span>\n <span class="token punctuation">{</span>\n id<span class="token punctuation">:</span> <span class="token number">3</span><span class="token punctuation">,</span>\n text<span class="token punctuation">:</span> <span class="token string">\'蓝色\'</span><span class="token punctuation">,</span>\n <span class="token punctuation">}</span><span class="token punctuation">,</span>\n <span class="token punctuation">{</span>\n id<span class="token punctuation">:</span> <span class="token number">10</span><span class="token punctuation">,</span>\n text<span class="token punctuation">:</span> <span class="token string">\'红色\'</span><span class="token punctuation">,</span>\n <span class="token punctuation">}</span><span class="token punctuation">,</span>\n <span class="token punctuation">{</span>\n id<span class="token punctuation">:</span> <span class="token number">30</span><span class="token punctuation">,</span>\n text<span class="token punctuation">:</span> <span class="token string">\'土豪金\'</span><span class="token punctuation">,</span>\n <span class="token punctuation">}</span><span class="token punctuation">,</span>\n <span class="token punctuation">{</span>\n id<span class="token punctuation">:</span> <span class="token number">137</span><span class="token punctuation">,</span>\n text<span class="token punctuation">:</span> <span class="token string">\'黑色\'</span><span class="token punctuation">,</span>\n <span class="token punctuation">}</span><span class="token punctuation">,</span>\n <span class="token punctuation">{</span>\n id<span class="token punctuation">:</span> <span class="token number">138</span><span class="token punctuation">,</span>\n text<span class="token punctuation">:</span> <span class="token string">\'灰色\'</span><span class="token punctuation">,</span>\n <span class="token punctuation">}</span><span class="token punctuation">,</span>\n<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">Component</span> <span class="token punctuation">{</span>\n <span class="token function">fetchSKUTree</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 keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span>resolve <span class="token operator">=></span> <span class="token punctuation">{</span>\n <span class="token function">resolve</span><span class="token punctuation">(</span>skuTree<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 <span class="token punctuation">}</span>\n\n <span class="token function">fetchSKU</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 keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span>resolve <span class="token operator">=></span> <span class="token punctuation">{</span>\n <span class="token function">resolve</span><span class="token punctuation">(</span>sku<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 <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>SKU</span>\n <span class="token attr-name">showSKULabel</span>\n <span class="token attr-name">onFetchGroup</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>fetchSKUTree<span class="token punctuation">}</span></span>\n <span class="token attr-name">onFetchSKU</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>fetchSKU<span class="token punctuation">}</span></span>\n <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><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>Simple</span> <span class="token punctuation">/></span></span><span class="token punctuation">,</span> mountNode<span class="token punctuation">)</span><span class="token punctuation">;</span>'},b.default.createElement(S)),b.default.createElement(U,{title:"flatten",id:"Demoflatten",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> SKU <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> <span class="token punctuation">{</span> flatten <span class="token punctuation">}</span> <span class="token operator">=</span> SKU<span class="token punctuation">;</span>\n\n<span class="token keyword">let</span> skus <span class="token operator">=</span> <span class="token punctuation">[</span>\n <span class="token punctuation">{</span> id<span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'颜色\'</span><span class="token punctuation">,</span> leaf<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">11</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'红色\'</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">12</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'蓝色\'</span><span class="token punctuation">}</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>\n <span class="token punctuation">{</span> id<span class="token punctuation">:</span> <span class="token number">2</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'尺寸\'</span><span class="token punctuation">,</span> leaf<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">21</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'大\'</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">22</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'小\'</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>\n\nconsole<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">flatten</span><span class="token punctuation">(</span>skus<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n<span class="token comment">/**\n * output:\n * [\n * {"skus":[{"k_id":1,"k":"颜色","v_id":11,"v":"红色"},{"k_id":2,"k":"尺寸","v_id":21,"v":"大"}]},\n * {"skus":[{"k_id":1,"k":"颜色","v_id":11,"v":"红色"},{"k_id":2,"k":"尺寸","v_id":22,"v":"小"}]}\n * {"skus":[{"k_id":1,"k":"颜色","v_id":12,"v":"蓝色"},{"k_id":2,"k":"尺寸","v_id":21,"v":"大"}]}\n * {"skus":[{"k_id":1,"k":"颜色","v_id":12,"v":"蓝色"},{"k_id":2,"k":"尺寸","v_id":22,"v":"小"}]}\n * ]\n */</span>\n\n<span class="token keyword">let</span> items <span class="token operator">=</span> <span class="token punctuation">[</span>\n <span class="token punctuation">{</span>\n <span class="token string">"price"</span><span class="token punctuation">:</span> <span class="token string">"10.00"</span><span class="token punctuation">,</span>\n <span class="token string">"code"</span><span class="token punctuation">:</span> <span class="token string">"AE86"</span><span class="token punctuation">,</span>\n <span class="token string">"skus"</span><span class="token punctuation">:</span><span class="token punctuation">[</span><span class="token punctuation">{</span><span class="token string">"k_id"</span><span class="token punctuation">:</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token string">"k"</span><span class="token punctuation">:</span><span class="token string">"颜色"</span><span class="token punctuation">,</span><span class="token string">"v_id"</span><span class="token punctuation">:</span><span class="token number">11</span><span class="token punctuation">,</span><span class="token string">"v"</span><span class="token punctuation">:</span><span class="token string">"红色"</span><span class="token punctuation">}</span><span class="token punctuation">,</span><span class="token punctuation">{</span><span class="token string">"k_id"</span><span class="token punctuation">:</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token string">"k"</span><span class="token punctuation">:</span><span class="token string">"尺寸"</span><span class="token punctuation">,</span><span class="token string">"v_id"</span><span class="token punctuation">:</span><span class="token number">22</span><span class="token punctuation">,</span><span class="token string">"v"</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<span class="token punctuation">]</span><span class="token punctuation">;</span>\nconsole<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">flatten</span><span class="token punctuation">(</span>skus<span class="token punctuation">,</span> items<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n\n<span class="token comment">/**\n * output:\n * [\n * {"skus":[{"k_id":1,"k":"颜色","v_id":11,"v":"红色"},{"k_id":2,"k":"尺寸","v_id":21,"v":"大"}]},\n * {\n * "price":"10.00",\n * "code":"AE86",\n * "skus":[{"k_id":1,"k":"颜色","v_id":11,"v":"红色"},{"k_id":2,"k":"尺寸","v_id":22,"v":"小"}]\n * },\n * {"skus":[{"k_id":1,"k":"颜色","v_id":12,"v":"蓝色"},{"k_id":2,"k":"尺寸","v_id":21,"v":"大"}]}\n * {"skus":[{"k_id":1,"k":"颜色","v_id":12,"v":"蓝色"},{"k_id":2,"k":"尺寸","v_id":22,"v":"小"}]}\n * ]\n */</span>\n\nReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span>\n <span class="token operator"><</span>p style<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>fontSize<span class="token punctuation">:</span> <span class="token number">14</span><span class="token punctuation">,</span> color<span class="token punctuation">:</span> <span class="token string">\'#333\'</span><span class="token punctuation">}</span><span class="token punctuation">}</span><span class="token operator">></span>请看代码<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</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>'},b.default.createElement(w)),b.default.createElement(U,{title:"isSame",id:"Demoissame",src:'<span class="token keyword">import</span> <span class="token punctuation">{</span> SKU <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> <span class="token punctuation">{</span> isSame <span class="token punctuation">}</span> <span class="token operator">=</span> SKU<span class="token punctuation">;</span>\n\n<span class="token keyword">let</span> skuA <span class="token operator">=</span> <span class="token punctuation">[</span>\n <span class="token punctuation">{</span> id<span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'颜色\'</span><span class="token punctuation">,</span> leaf<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">11</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'红色\'</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">12</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'蓝色\'</span><span class="token punctuation">}</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>\n <span class="token punctuation">{</span> id<span class="token punctuation">:</span> <span class="token number">2</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'尺寸\'</span><span class="token punctuation">,</span> leaf<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">21</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'大\'</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">22</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'小\'</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>\n\n<span class="token keyword">let</span> skuB <span class="token operator">=</span> <span class="token punctuation">[</span>\n <span class="token punctuation">{</span> id<span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'颜色\'</span><span class="token punctuation">,</span> leaf<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">11</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'红色\'</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">12</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'蓝色\'</span><span class="token punctuation">}</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>\n <span class="token punctuation">{</span> id<span class="token punctuation">:</span> <span class="token number">2</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'尺寸\'</span><span class="token punctuation">,</span> leaf<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">21</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'大\'</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">22</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'小\'</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>\n\n<span class="token keyword">let</span> skuC <span class="token operator">=</span> <span class="token punctuation">[</span>\n <span class="token punctuation">{</span> id<span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'颜色\'</span><span class="token punctuation">,</span> leaf<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">11</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'红色\'</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">12</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'蓝色\'</span><span class="token punctuation">}</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>\n <span class="token punctuation">{</span> id<span class="token punctuation">:</span> <span class="token number">2</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'尺寸\'</span><span class="token punctuation">,</span> leaf<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">22</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'小\'</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">21</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'大\'</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>\n\n<span class="token keyword">let</span> skuD <span class="token operator">=</span> <span class="token punctuation">[</span>\n <span class="token punctuation">{</span> id<span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'颜色\'</span><span class="token punctuation">,</span> leaf<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">11</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'红色\'</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">12</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'蓝色\'</span><span class="token punctuation">}</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">,</span>\n <span class="token punctuation">{</span> id<span class="token punctuation">:</span> <span class="token number">3</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'尺寸\'</span><span class="token punctuation">,</span> leaf<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">21</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'大\'</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>id<span class="token punctuation">:</span> <span class="token number">22</span><span class="token punctuation">,</span> text<span class="token punctuation">:</span> <span class="token string">\'小\'</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>\n\nconsole<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">isSame</span><span class="token punctuation">(</span>skuA<span class="token punctuation">,</span> skuB<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\nconsole<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">isSame</span><span class="token punctuation">(</span>skuA<span class="token punctuation">,</span> skuC<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\nconsole<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">isSame</span><span class="token punctuation">(</span>skuA<span class="token punctuation">,</span> skuD<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>\n\n<span class="token comment">/**\n * output:\n *\n * true\n * false\n * false\n */</span>\n\nReactDOM<span class="token punctuation">.</span><span class="token function">render</span><span class="token punctuation">(</span>\n <span class="token operator"><</span>p style<span class="token operator">=</span><span class="token punctuation">{</span><span class="token punctuation">{</span>fontSize<span class="token punctuation">:</span> <span class="token number">14</span><span class="token punctuation">,</span> color<span class="token punctuation">:</span> <span class="token string">\'#333\'</span><span class="token punctuation">}</span><span class="token punctuation">}</span><span class="token operator">></span>请看代码<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</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>'},b.default.createElement(K)),b.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<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>className</td>\n<td>自定义额外类名</td>\n<td>string</td>\n<td><code>\'\'</code></td>\n<td></td>\n</tr>\n<tr>\n<td>value</td>\n<td>当前选中的sku列表</td>\n<td>array</td>\n<td><code>[]</code></td>\n<td></td>\n</tr>\n<tr>\n<td>maxSize</td>\n<td>最大规格名称数</td>\n<td>number</td>\n<td><code>3</code></td>\n<td></td>\n</tr>\n<tr>\n<td>maxSKUTextLength</td>\n<td>规格名称文字最大长度</td>\n<td>number</td>\n<td><code>4</code></td>\n<td></td>\n</tr>\n<tr>\n<td>maxLeafTextLength</td>\n<td>规格值文字最大长度</td>\n<td>number</td>\n<td><code>20</code></td>\n<td></td>\n</tr>\n<tr>\n<td>skuTree</td>\n<td>可选的规格列表</td>\n<td>array</td>\n<td><code>[]</code></td>\n<td></td>\n</tr>\n<tr>\n<td>optionValue</td>\n<td>自定义sku的id的key值</td>\n<td>string</td>\n<td><code>\'id\'</code></td>\n<td></td>\n</tr>\n<tr>\n<td>optionText</td>\n<td>自定义sku的文案的key值</td>\n<td>string</td>\n<td><code>\'text\'</code></td>\n<td></td>\n</tr>\n<tr>\n<td>onFetchGroup</td>\n<td>异步获取可选的规格列表,如“颜色”、“尺寸”</td>\n<td>function</td>\n<td><code>Promise</code></td>\n<td></td>\n</tr>\n<tr>\n<td>onFetchSKU</td>\n<td>异步获取单个规格可选的值,如“红色”、“蓝色”</td>\n<td>function</td>\n<td><code>Promise</code></td>\n<td></td>\n</tr>\n<tr>\n<td>onCreateGroup</td>\n<td>创建新的规格名,如“星座”</td>\n<td>function</td>\n<td><code>Promise</code></td>\n<td></td>\n</tr>\n<tr>\n<td>onCreateSKU</td>\n<td>创建新的规格值,如“处女座”</td>\n<td>function</td>\n<td><code>Promise</code></td>\n<td></td>\n</tr>\n<tr>\n<td>onChange</td>\n<td>当sku发生改变时的回调,返回值为sku当前value</td>\n<td>function</td>\n<td><code>noop</code></td>\n<td></td>\n</tr>\n<tr>\n<td>prefix</td>\n<td>自定义前缀</td>\n<td>string</td>\n<td>\'rc-sku\'</td>\n<td>null</td>\n</tr>\n<tr>\n<td>showAddSKUImage</td>\n<td>是否显示添加规格图片按钮</td>\n<td>bool</td>\n<td>true</td>\n<td>false</td>\n</tr>\n<tr>\n<td>showSKULabel</td>\n<td>是否显示规格 label</td>\n<td>bool</td>\n<td>false</td>\n<td>true</td>\n</tr>\n<tr>\n<td>groupButtonAddon</td>\n<td>规格列表按钮自定义内容</td>\n<td>node</td>\n<td>null</td>\n<td>null</td>\n</tr>\n</tbody>\n</table>\n<h4 class="anchor-heading"><a href="#gong-ju-fang-fa">¶</a><a href="javascript:void(0)" id="gong-ju-fang-fa" class="anchor-point"></a>工具方法</h4>\n<p>为了更方便操作规格数据,SKU组件提供了一些工具方法</p>\n<h4 class="anchor-heading"><a href="#sku-flatten-sku-items-option">¶</a><a href="javascript:void(0)" id="sku-flatten-sku-items-option" class="anchor-point"></a>SKU.flatten(sku, items, options)</h4>\n<p>通过计算笛卡尔积,将树形的value变成扁平的数组</p>\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>sku</td>\n<td>当前选中规格的value</td>\n<td>array</td>\n<td><code>[]</code></td>\n<td></td>\n</tr>\n<tr>\n<td>items</td>\n<td>当前已存在的数据</td>\n<td>array</td>\n<td><code>[]</code></td>\n<td></td>\n</tr>\n<tr>\n<td>options</td>\n<td>可配置参数</td>\n<td>object</td>\n<td><code>{}</code></td>\n<td><code>optionValue: \'id\', optionText: \'text\'</code></td>\n</tr>\n</tbody>\n</table>'}))}}]),s}(v.Component);s.default=E}});