tab.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <div>
  3. <nut-docheader
  4. :name="$route.name"
  5. :chName="$route.params.chnName"
  6. type="Component"
  7. desc="选项卡组件。"
  8. :showQrCode="true"></nut-docheader>
  9. <!-- <h6>一种用于tab切换的选项卡,支持内容区自定义元素。</h6> -->
  10. <!-- DEMO区域 -->
  11. <h5>示例</h5>
  12. <h6>默认用法</h6>
  13. <nut-codebox :code="demo1" :imgUrl="['../asset/img/demo/tab1.png']"></nut-codebox>
  14. <!-- <pre><code v-highlight v-text="demo1"></code></pre> -->
  15. <h6>在第二个标签上增加图标,页签导航条在左侧(支持导航条在上下左右位置)</h6>
  16. <nut-codebox :code="demo2" :imgUrl="['../asset/img/demo/tab2.png']"></nut-codebox>
  17. <!-- <pre><code v-highlight v-text="demo2"></code></pre> -->
  18. <h6>隐藏tab下面内容,跳转页面</h6>
  19. <nut-codebox :code="demo3" :imgUrl="['../asset/img/demo/tab3.png']"></nut-codebox>
  20. <!-- <pre><code v-highlight v-text="demo3"></code></pre> -->
  21. <h6>给tab页签增加className,可以自定义样式,默认选中第二个标签</h6>
  22. <nut-codebox :code="demo4" :imgUrl="['../asset/img/demo/tab4.png']"></nut-codebox>
  23. <nut-codebox :code="demo5"></nut-codebox>
  24. <!-- <pre><code v-highlight v-text="demo4"></code></pre>
  25. <pre><code v-highlight v-text="demo5"></code></pre> -->
  26. <h5>Props</h5>
  27. <div class="tbl-wrapper">
  28. <table class="u-full-width">
  29. <thead>
  30. <tr>
  31. <th>参数</th>
  32. <th>说明</th>
  33. <th>类型</th>
  34. <th>默认值</th>
  35. <th>可选值</th>
  36. </tr>
  37. </thead>
  38. <tbody>
  39. <tr>
  40. <td>defIndex</td>
  41. <td>默认选中的tab</td>
  42. <td>Number</td>
  43. <td>0</td>
  44. <td>--</td>
  45. </tr>
  46. <tr>
  47. <td>contentShow</td>
  48. <td>是否显示tab下面的内容</td>
  49. <td>boolean</td>
  50. <td>true</td>
  51. <td>true/false</td>
  52. </tr>
  53. <tr>
  54. <td>tabTitle</td>
  55. <td>tab选项卡标题</td>
  56. <td>string</td>
  57. <td>--</td>
  58. <td>--</td>
  59. </tr>
  60. <tr>
  61. <td>iconUrl</td>
  62. <td>tab标签中的图片地址</td>
  63. <td>string</td>
  64. <td>--</td>
  65. <td>--</td>
  66. </tr>
  67. <tr>
  68. <td>tabLink</td>
  69. <td>tab标签中的跳转链接地址</td>
  70. <td>string</td>
  71. <td>--</td>
  72. <td>--</td>
  73. </tr>
  74. <tr>
  75. <td>positionNav</td>
  76. <td>tab标签的位置</td>
  77. <td>string</td>
  78. <td>'top'</td>
  79. <td>'top'/'left'/'right'/'bottom'</td>
  80. </tr>
  81. </tbody>
  82. </table>
  83. </div>
  84. <h5>Events</h5>
  85. <div class="tbl-wrapper">
  86. <table class="u-full-width">
  87. <thead>
  88. <tr>
  89. <th>事件名</th>
  90. <th>说明</th>
  91. <th>回调参数</th>
  92. </tr>
  93. </thead>
  94. <tbody>
  95. <tr>
  96. <td>tab-switch</td>
  97. <td>点击tab标签时触发事件</td>
  98. <td>返回index值和自身对象event</td>
  99. </tr>
  100. </tbody>
  101. </table>
  102. </div>
  103. </div>
  104. </template>
  105. <script>
  106. import Vue from 'vue';
  107. export default {
  108. data(){
  109. return{
  110. demo1:
  111. `<nut-tab @tabSwitch="tab-switch">
  112. <nut-tab-panel tabTitle="页签名称1">11</nut-tab-panel>
  113. <nut-tab-panel tabTitle="页签名称2">
  114. <h2>22</h2>
  115. </nut-tab-panel>
  116. <nut-tab-panel tabTitle="页签名称3">33</nut-tab-panel>
  117. <nut-tab-panel tabTitle="页签名称4">44</nut-tab-panel>
  118. </nut-tab>`,
  119. demo2:
  120. `<nut-tab @tabSwitch="tab-switch" positionNav="left">
  121. <nut-tab-panel tabTitle="页签1">11</nut-tab-panel>
  122. <nut-tab-panel tabTitle="页签2" iconUrl="图片地址">
  123. <h2>22</h2>
  124. </nut-tab-panel>
  125. <nut-tab-panel tabTitle="页签3">33</nut-tab-panel>
  126. <nut-tab-panel tabTitle="页签4">44</nut-tab-panel>
  127. </nut-tab>`,
  128. demo3:
  129. `<nut-tab @tabSwitch="tab-switch" :contentShow="false">
  130. <nut-tab-panel tabTitle="页签1">11</nut-tab-panel>
  131. <nut-tab-panel tabTitle="页签2" tabLink="http://www.baidu.com">
  132. <h2>22</h2>
  133. </nut-tab-panel>
  134. <nut-tab-panel tabTitle="页签3" tabLink="http://www.jd.com">33</nut-tab-panel>
  135. </nut-tab>`,
  136. demo4:
  137. `<nut-tab
  138. :defIndex="1"
  139. class="customer-css"
  140. @tabSwitch="tab-switch"
  141. :contentShow="true"
  142. >
  143. <nut-tab-panel tabTitle="页签1">11</nut-tab-panel>
  144. <nut-tab-panel tabTitle="页签2">
  145. <h2>22</h2>
  146. </nut-tab-panel>
  147. <nut-tab-panel tabTitle="页签3">33</nut-tab-panel>
  148. <nut-tab-panel tabTitle="页签4">44</nut-tab-panel>
  149. </nut-tab>`,
  150. demo5:
  151. `.customer-css .nut-tab-active .nut-tab-link[data-v-240d0c90]{
  152. border-bottom: 1px solid #0E90D2;
  153. background: #F5F7FA;
  154. }
  155. .customer-css .nut-title-nav-list[data-v-240d0c90]{
  156. background: #fff;
  157. border-left: 1px solid #F5F7FA;
  158. }
  159. .customer-css .nut-title-nav-list[data-v-240d0c90]:first-child{
  160. border-left: 0;
  161. };
  162. .customer-css .nut-tab-active[data-v-240d0c90]{
  163. background: #F5F7FA;
  164. border: 0;
  165. }
  166. .customer-css .nut-tab-link[data-v-240d0c90]{
  167. width:100%;
  168. }`,
  169. }
  170. },
  171. methods:{
  172. tabSwitch:function(index,event){
  173. console.log(index+'--'+event.target);
  174. },
  175. }
  176. }
  177. </script>
  178. <style>
  179. .customer-css .nut-tab-active .nut-tab-link[data-v-240d0c90]{
  180. border-bottom: 1px solid #0E90D2;
  181. background: #F5F7FA;
  182. }
  183. .customer-css .nut-title-nav-list[data-v-240d0c90]{
  184. background: #fff;
  185. border-left: 1px solid #F5F7FA;
  186. }
  187. .customer-css .nut-title-nav-list[data-v-240d0c90]:first-child{
  188. border-left: 0;
  189. };
  190. .customer-css .nut-tab-active[data-v-240d0c90]{
  191. background: #F5F7FA;
  192. border: 0;
  193. }
  194. .customer-css .nut-tab-link[data-v-240d0c90]{
  195. width:100%;
  196. }
  197. </style>