searchbar.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. <!-- <a class="button button-primary" href="/demo.html#/searchbar" target="_blank">Demo</a> -->
  10. <!-- <h6>搜索栏。</h6> -->
  11. <!-- DEMO区域 -->
  12. <h5>示例</h5>
  13. <h6>默认用法</h6>
  14. <nut-codebox :code="demo1" :imgUrl="['../asset/img/demo/searchBar1.png']"></nut-codebox>
  15. <!-- <pre><code v-highlight v-text="demo1"></code></pre> -->
  16. <h6>右侧搜索按钮可根据需要进行配置</h6>
  17. <nut-codebox :code="demo2" :imgUrl="['../asset/img/demo/searchBar2.png']"></nut-codebox>
  18. <!-- <pre><code v-highlight v-text="demo2"></code></pre> -->
  19. <h6>可配置输入框前面是否显示搜索图标(图标可配置)、输入框高度、右侧是否显示文字按钮以及文字按钮宽度、显示文字、文字颜色</h6>
  20. <nut-codebox :code="demo3" :imgUrl="['../asset/img/demo/searchBar3.png']"></nut-codebox>
  21. <!-- <pre><code v-highlight v-text="demo3"></code></pre> -->
  22. <h6>可配置获取输入框焦点事件、输入事件、失去焦点事件、默认提交事件</h6>
  23. <nut-codebox :code="demo4" :imgUrl="['../asset/img/demo/searchBar1.png']"></nut-codebox>
  24. <nut-codebox :code="demo5"></nut-codebox>
  25. <!-- <pre><code v-highlight v-text="demo4"></code></pre>
  26. <pre><code v-highlight v-text="demo5"></code></pre> -->
  27. <h5>Props</h5>
  28. <div class="tbl-wrapper">
  29. <table class="u-full-width">
  30. <thead>
  31. <tr>
  32. <th>参数</th>
  33. <th>说明</th>
  34. <th>类型</th>
  35. <th>默认值</th>
  36. <th>可选值</th>
  37. </tr>
  38. </thead>
  39. <tbody>
  40. <tr>
  41. <td>height</td>
  42. <td>输入框的高度,单位为rem</td>
  43. <td>String</td>
  44. <td>'0.6'</td>
  45. <td>--</td>
  46. </tr>
  47. <tr>
  48. <td>width</td>
  49. <td>右侧搜索按钮的宽度,单位为rem</td>
  50. <td>String</td>
  51. <td>'0.6'</td>
  52. <td>--</td>
  53. </tr>
  54. <tr>
  55. <td>color</td>
  56. <td>右侧文字搜索按钮字体颜色</td>
  57. <td>String</td>
  58. <td>'#222'</td>
  59. <td>--</td>
  60. </tr>
  61. <tr>
  62. <td>textInfo</td>
  63. <td>右侧文字搜索按钮文案</td>
  64. <td>String</td>
  65. <td>'搜索'</td>
  66. <td>--</td>
  67. </tr>
  68. <tr>
  69. <td>icon</td>
  70. <td>输入框前面icon及右侧图标搜索按钮icon链接</td>
  71. <td>String</td>
  72. <td></td>
  73. <td>--</td>
  74. </tr>
  75. <tr>
  76. <td>hasIcon</td>
  77. <td>是否显示输入框前面的icon</td>
  78. <td>Boolean</td>
  79. <td>false</td>
  80. <td>--</td>
  81. </tr>
  82. <tr>
  83. <td>placeText</td>
  84. <td>输入框placeholder内容</td>
  85. <td>String</td>
  86. <td>'请输入内容...'</td>
  87. <td>--</td>
  88. </tr>
  89. <tr>
  90. <td>hasSearchButton</td>
  91. <td>是否显示右侧搜索按钮</td>
  92. <td>Boolean</td>
  93. <td>true</td>
  94. <td>--</td>
  95. </tr>
  96. <tr>
  97. <td>hasTextButton</td>
  98. <td>右侧搜索按钮是否为文字按钮</td>
  99. <td>Boolean</td>
  100. <td>false</td>
  101. <td>--</td>
  102. </tr>
  103. </tbody>
  104. </table>
  105. </div>
  106. <h5>Events</h5>
  107. <div class="tbl-wrapper">
  108. <table class="u-full-width">
  109. <thead>
  110. <tr>
  111. <th>事件名</th>
  112. <th>说明</th>
  113. <th>回调</th>
  114. </tr>
  115. </thead>
  116. <tbody>
  117. <tr>
  118. <td>focus</td>
  119. <td>输入框获取焦点时触发事件</td>
  120. <td>--</td>
  121. </tr>
  122. <tr>
  123. <td>input</td>
  124. <td>输入框输入内容时触发事件</td>
  125. <td>--</td>
  126. </tr>
  127. <tr>
  128. <td>blur</td>
  129. <td>输入框失去焦点时触发事件</td>
  130. <td>--</td>
  131. </tr>
  132. <tr>
  133. <td>submit</td>
  134. <td>默认提交事件</td>
  135. <td>--</td>
  136. </tr>
  137. </tbody>
  138. </table>
  139. </div>
  140. </div>
  141. </template>
  142. <script>
  143. export default {
  144. data() {
  145. return {
  146. demo1: `<nut-searchbar placeText="请输入自定义文案"></nut-searchbar>`,
  147. demo2: `<nut-searchbar
  148. placeText="请输入自定义文案"
  149. :hasSearchButton="false"
  150. ></nut-searchbar>`,
  151. demo3: `<nut-searchbar
  152. placeText="ERP/姓名/邮箱"
  153. :hasIcon="true"
  154. :hasTextButton="true"
  155. textInfo="搜索"
  156. width="1"
  157. height="1"
  158. color="#f23030"
  159. ></nut-searchbar>`,
  160. demo4: `<nut-searchbar
  161. placeText="请输入自定义文案"
  162. @focus="focusFun"
  163. @input="inputFun"
  164. @blur="blurFun"
  165. @submit="submitFun"
  166. ></nut-searchbar>`,
  167. demo5: `export default {
  168. methods: {
  169. focusFun() {
  170. console.log('获取焦点操作!');
  171. },
  172. inputFun() {
  173. alert('您正在输入...');
  174. },
  175. blurFun() {
  176. console.log('您已失去焦点!');
  177. },
  178. submitFun() {
  179. console.log('默认提交操作!');
  180. }
  181. }
  182. }`
  183. }
  184. },
  185. methods:{
  186. focusFun() {
  187. console.log('获取焦点操作!');
  188. },
  189. inputFun() {
  190. alert('您正在输入...');
  191. },
  192. blurFun() {
  193. console.log('您已失去焦点!');
  194. },
  195. submitFun() {
  196. console.log('默认提交操作!');
  197. }
  198. }
  199. }
  200. </script>
  201. <style></style>