You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

178 regels
7.6 KiB

  1. <template>
  2. <view>
  3. <l-title>输入框:</l-title>
  4. <view class="bg-white">
  5. <l-input title="标题" placeholder="请输入内容" left />
  6. <l-input title="右对齐" placeholder="文字右对齐版" left />
  7. <l-input title="禁用" placeholder="请输入内容(禁用)" disabled left />
  8. <l-input title="标题" placeholder="请输入内容(带后缀图标)" left>
  9. <l-icon slot="suffix" type="copy" color="red" />
  10. </l-input>
  11. <l-input title="标题" placeholder="请输入内容(带后缀按钮)" left>
  12. <l-button slot="suffix" color="green" shadow>按钮</l-button>
  13. </l-input>
  14. <l-input title="标题" placeholder="请输入内容(带后缀标签)" left>
  15. <l-tag slot="suffix" color="blue" capsule radius>
  16. <text slot="icon">中国大陆</text>
  17. +86
  18. </l-tag>
  19. </l-input>
  20. <l-input v-model="text" title="请输入" placeholder="双向绑定测试" />
  21. <view class="text-center">当前输入内容: {{ text }}</view>
  22. </view>
  23. <l-demo-description>
  24. 输入框使用 l-input 标签;添加 title属性可以设置左侧的标题文字;添加 placeholder 属性可以设置无内容的占位文本;
  25. 标签内的 slot="suffix" 插槽可以放置后缀按钮、标签等
  26. </l-demo-description>
  27. <l-title>选择器:</l-title>
  28. <view class="bg-white">
  29. <l-select v-model="select1" :range="['男生', '女生']" title="选择器" placeholder="请选择性别..." />
  30. <view class="text-center">当前选择: {{ select1 }}</view>
  31. <!-- #ifndef MP-ALIPAY -->
  32. <l-select
  33. v-model="select2"
  34. :range="[['安卓', 'iOS', 'WP'], ['QQ登录', '微信登录']]"
  35. title="双列选择器"
  36. multiple
  37. />
  38. <view class="text-center">当前选择: {{ select2.join(',') }}</view>
  39. <l-select
  40. v-model="select3"
  41. :range="[['红色', '绿色', '蓝色'], ['纯棉', '化纤', '混纺'], ['M', 'L', 'XL']]"
  42. title="三列选择器"
  43. multiple
  44. />
  45. <view class="text-center">当前选择: {{ select3.join(',') }}</view>
  46. <!-- #endif -->
  47. </view>
  48. <l-demo-description>
  49. 选择器使用 l-select 标签;可选项请绑定为 range 属性,当前选定的值通过 v-model 绑定;
  50. <!-- #ifndef MP-ALIPAY -->
  51. 如果是两列、三列选择器,还需要额外添加 multiple 属性;title 属性是标题文字; 注意多列选择器的 range
  52. 是一个双层嵌套数组,而 v-model 是一个数组
  53. <!-- #endif -->
  54. </l-demo-description>
  55. <l-title>日期/时间选择:</l-title>
  56. <view class="bg-white">
  57. <l-date-picker v-model="datePicker" title="日期" placeholder="请选择日期..." />
  58. <view class="text-center">当前已选日期: {{ datePicker }}</view>
  59. <l-time-picker v-model="timePicker" title="时间" placeholder="请选择时间..." />
  60. <view class="text-center">当前已选时间: {{ timePicker }}</view>
  61. </view>
  62. <l-demo-description>
  63. 日期选择器使用 l-date-picker 标签;时间选择器使用 l-time-picker 标签; 两者都可以使用 title、placeholder
  64. 属性来设置标题、占位文字; 两者都有 start、end 属性来设置选择的起点和终点,注意是字符串格式
  65. </l-demo-description>
  66. <!-- #ifdef MP-WEIXIN -->
  67. <l-title>地区选择:</l-title>
  68. <view class="bg-white">
  69. <l-region-picker v-model="regionPicker" title="家乡" placeholder="请选择地区..." />
  70. <view class="text-center">当前已选地区: {{ regionPicker.join(',') }}</view>
  71. </view>
  72. <l-demo-description>地区选择器使用 l-region-picker 标签;当前仅微信小程序支持</l-demo-description>
  73. <!-- #endif -->
  74. <l-title>开关:</l-title>
  75. <view class="bg-white">
  76. <l-switch title="普通开关" />
  77. <!-- #ifndef MP-ALIPAY -->
  78. <l-switch title="自定义颜色" color="red" />
  79. <l-switch title="自定义图标" icon="sex" />
  80. <l-switch title="方形开关" radius />
  81. <!-- #endif -->
  82. <l-switch v-model="switchValue" title="双向绑定" />
  83. <view class="text-center">当前开关状态: {{ switchValue }}</view>
  84. </view>
  85. <l-demo-description>
  86. 开关使用 l-switch 标签;添加 title 属性可以设置标题文本;
  87. <!-- #ifndef MP-ALIPAY -->
  88. 添加 color 属性可以设置颜色; 添加 radius 属性将变成圆角方形开关;添加 icon="sex" 属性将变为性别选择开关
  89. <!-- #endif -->
  90. </l-demo-description>
  91. <l-title>单选框:</l-title>
  92. <view class="bg-white">
  93. <radio-group>
  94. <l-radio v-model="radioValue" title="单选框1" radioValue="1" />
  95. <l-radio v-model="radioValue" title="单选框2" radioValue="2" />
  96. <!-- #ifndef MP-ALIPAY -->
  97. <l-radio v-model="radioValue" title="点状单选框3" radioValue="3" point />
  98. <l-radio v-model="radioValue" title="自定义颜色单选框4" radioValue="4" color="blue" />
  99. <!-- #endif -->
  100. <view class="text-center">当前单选框状态: {{ radioValue }}</view>
  101. </radio-group>
  102. </view>
  103. <l-demo-description>
  104. 单选框使用 l-radio 标签,通过 title 属性绑定标题文字,通过 radioValue 属性绑定值;
  105. 同一组单选框,请绑定同一个变量作为它们的 v-model,因此无需使用 radio-group;
  106. <!-- #ifndef MP-ALIPAY -->
  107. 使用 color 属性设置颜色;添加 point 属性将单选框转为点状风格
  108. <!-- #endif -->
  109. </l-demo-description>
  110. <l-title>复选框:</l-title>
  111. <view class="bg-white">
  112. <checkbox-group>
  113. <l-checkbox v-model="checkboxValue" title="复选框1" checkboxValue="A" />
  114. <l-checkbox v-model="checkboxValue" title="复选框2" checkboxValue="B" />
  115. <l-checkbox v-model="checkboxValue" title="圆形复选框3" checkboxValue="C" round />
  116. <!-- #ifndef MP-ALIPAY -->
  117. <l-checkbox v-model="checkboxValue" title="自定义颜色复选框3" checkboxValue="D" color="blue" />
  118. <!-- #endif -->
  119. <view class="text-center">当前复选框状态: [{{ checkboxValue.join(',') }}]</view>
  120. </checkbox-group>
  121. </view>
  122. <l-demo-description>
  123. 复选框使用 l-checkbox 标签,它使用 checkboxValue 属性绑定选项的值; 请将同一组复选框绑定相同的变量作为
  124. v-model,无需使用 checkbox-group; 使用 title 属性来设置标题文本;添加 round 属性转为圆形复选框;
  125. <!-- #ifndef MP-ALIPAY -->
  126. 使用 color 属性设置复选框颜色;
  127. <!-- #endif -->
  128. </l-demo-description>
  129. <l-title>图片上传:</l-title>
  130. <view class="bg-white">
  131. <l-upload v-model="imgList" number="3" />
  132. <view class="text-center">当前图片数量: {{ imgList.length }}</view>
  133. </view>
  134. <l-demo-description>图片上传使用 l-upload 标签;属性 number 表示图片张数上限</l-demo-description>
  135. <l-title>多行文本:</l-title>
  136. <view class="bg-white">
  137. <l-textarea v-model="textareaValue" placeholder="输入点什么..." />
  138. <view class="text-center">当前输入内容: {{ textareaValue }}</view>
  139. </view>
  140. <l-demo-description>多行文本使用 l-textarea 标签;使用 placeholder 属性来设置占位文本</l-demo-description>
  141. </view>
  142. </template>
  143. <script>
  144. export default {
  145. data() {
  146. return {
  147. text: '',
  148. select1: '男生',
  149. select2: ['安卓', 'QQ登录'],
  150. select3: ['红色', '纯棉', 'M'],
  151. datePicker: null,
  152. timePicker: null,
  153. regionPicker: [],
  154. switchValue: false,
  155. radioValue: '1',
  156. checkboxValue: [],
  157. imgList: [],
  158. textareaValue: 'xxx'
  159. }
  160. }
  161. }
  162. </script>