buttonstatus.uvue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <script>
  2. import { ItemType } from '@/components/enum-data/enum-data-types'
  3. export default {
  4. data() {
  5. return {
  6. plain_boolean: false,
  7. disabled_boolean: false,
  8. default_style: false,
  9. size_enum: [{ "value": 0, "name": "default" }, { "value": 1, "name": "mini" }] as ItemType[],
  10. size_enum_current: 0,
  11. type_enum: [{ "value": 0, "name": "default" }, { "value": 1, "name": "primary" }, { "value": 2, "name": "warn" }] as ItemType[],
  12. type_enum_current: 0,
  13. count: 0,
  14. text: 'uni-app-x'
  15. }
  16. },
  17. methods: {
  18. button_click() {
  19. console.log("组件被点击时触发")
  20. this.count++
  21. },
  22. button_touchstart() { console.log("手指触摸动作开始") },
  23. button_touchmove() { console.log("手指触摸后移动") },
  24. button_touchcancel() { console.log("手指触摸动作被打断,如来电提醒,弹窗") },
  25. button_touchend() { console.log("手指触摸动作结束") },
  26. button_tap() { console.log("手指触摸后马上离开") },
  27. button_longpress() { console.log("如果一个组件被绑定了 longpress 事件,那么当用户长按这个组件时,该事件将会被触发。") },
  28. change_plain_boolean(checked : boolean) { this.plain_boolean = checked },
  29. change_disabled_boolean(checked : boolean) { this.disabled_boolean = checked },
  30. change_default_style(checked : boolean) { this.default_style = checked },
  31. radio_change_size_enum(checked : number) { this.size_enum_current = checked },
  32. radio_change_type_enum(checked : number) { this.type_enum_current = checked },
  33. confirm_text_input(value : string) { this.text = value }
  34. }
  35. }
  36. </script>
  37. <template>
  38. <!-- #ifdef APP -->
  39. <scroll-view direction="vertical" style="flex:1">
  40. <!-- #endif -->
  41. <view class="main">
  42. <!--type-->
  43. <view class="container">
  44. <button style="margin: 10px;" :disabled="disabled_boolean" :size="size_enum[size_enum_current].name"
  45. :type="type_enum[0].name" :plain="plain_boolean" @click="button_click" @touchstart="button_touchstart"
  46. @touchmove="button_touchmove" @touchcancel="button_touchcancel" @touchend="button_touchend" @tap="button_tap"
  47. @longpress="button_longpress" class="btn" :class="default_style ? 'custom-btn' : ''">
  48. type-default
  49. </button>
  50. </view>
  51. <view class="container">
  52. <button style="margin: 10px;" :disabled="disabled_boolean" :size="size_enum[size_enum_current].name"
  53. :type="type_enum[1].name" :plain="plain_boolean" @click="button_click" @touchstart="button_touchstart"
  54. @touchmove="button_touchmove" @touchcancel="button_touchcancel" @touchend="button_touchend" @tap="button_tap"
  55. @longpress="button_longpress" class="btn" :class="default_style ? 'custom-btn' : ''">
  56. type-primary
  57. </button>
  58. </view>
  59. <view class="container">
  60. <button style="margin: 10px;" :disabled="disabled_boolean" :size="size_enum[size_enum_current].name"
  61. :type="type_enum[2].name" :plain="plain_boolean" @click="button_click" @touchstart="button_touchstart"
  62. @touchmove="button_touchmove" @touchcancel="button_touchcancel" @touchend="button_touchend" @tap="button_tap"
  63. @longpress="button_longpress" class="btn" :class="default_style ? 'custom-btn' : ''">
  64. type-warn
  65. </button>
  66. </view>
  67. <!--size-->
  68. <view class="container">
  69. <button style="margin: 10px;" :disabled="disabled_boolean" :size="size_enum[0].name"
  70. :type="type_enum[type_enum_current].name" :plain="plain_boolean" @click="button_click"
  71. @touchstart="button_touchstart" @touchmove="button_touchmove" @touchcancel="button_touchcancel"
  72. @touchend="button_touchend" @tap="button_tap" @longpress="button_longpress" class="btn"
  73. :class="default_style ? 'custom-btn' : ''" :hover-class="default_style ? 'is-hover' : 'button-hover'">
  74. size-default
  75. </button>
  76. </view>
  77. <view class="container">
  78. <button style="margin: 10px;" :disabled="disabled_boolean" :size="size_enum[1].name"
  79. :type="type_enum[type_enum_current].name" :plain="plain_boolean" @click="button_click"
  80. @touchstart="button_touchstart" @touchmove="button_touchmove" @touchcancel="button_touchcancel"
  81. @touchend="button_touchend" @tap="button_tap" @longpress="button_longpress" class="btn"
  82. :class="default_style ? 'custom-btn' : ''" >
  83. size-mini
  84. </button>
  85. </view>
  86. <!--plain-->
  87. <view class="container">
  88. <button style="margin: 10px;" :disabled="disabled_boolean" :size="size_enum[size_enum_current].name"
  89. :type="type_enum[type_enum_current].name" :plain="true" @click="button_click" @touchstart="button_touchstart"
  90. @touchmove="button_touchmove" @touchcancel="button_touchcancel" @touchend="button_touchend" @tap="button_tap"
  91. @longpress="button_longpress" class="btn" :class="default_style ? 'custom-btn' : ''"
  92. :hover-class="default_style ? 'is-hover' : 'button-hover'">
  93. plain=true
  94. </button>
  95. <button style="margin: 10px;" :disabled="disabled_boolean" :size="size_enum[size_enum_current].name"
  96. type="primary" :plain="true" @click="button_click" @touchstart="button_touchstart"
  97. @touchmove="button_touchmove" @touchcancel="button_touchcancel" @touchend="button_touchend" @tap="button_tap"
  98. @longpress="button_longpress" class="btn" :class="default_style ? 'custom-btn' : ''"
  99. :hover-class="default_style ? 'is-hover' : 'button-hover'">
  100. plain=true type=primary
  101. </button>
  102. <button style="margin: 10px;" :disabled="disabled_boolean" :size="size_enum[size_enum_current].name"
  103. type="warn" :plain="true" @click="button_click" @touchstart="button_touchstart"
  104. @touchmove="button_touchmove" @touchcancel="button_touchcancel" @touchend="button_touchend" @tap="button_tap"
  105. @longpress="button_longpress" class="btn" :class="default_style ? 'custom-btn' : ''"
  106. :hover-class="default_style ? 'is-hover' : 'button-hover'">
  107. plain=true type=warn
  108. </button>
  109. </view>
  110. <view class="container">
  111. <button style="margin: 10px;" :disabled="disabled_boolean" :size="size_enum[size_enum_current].name"
  112. :type="type_enum[type_enum_current].name" :plain="false" @click="button_click" @touchstart="button_touchstart"
  113. @touchmove="button_touchmove" @touchcancel="button_touchcancel" @touchend="button_touchend" @tap="button_tap"
  114. @longpress="button_longpress" class="btn" :class="default_style ? 'custom-btn' : ''"
  115. >
  116. plain-false
  117. </button>
  118. </view>
  119. </view>
  120. <view class="container">
  121. <button style="margin: 10px;position: relative;text-align:left;padding:5px;color: #ffffff;background-color: #1AAD19;
  122. font-size: 10px;line-height: 2;" :disabled="disabled_boolean" hover-class="is-hover">
  123. custom-btn
  124. </button>
  125. <button style="margin: 10px;position: relative;text-align:left;padding:5px;color: #ffffff;background-color: #1AAD19;
  126. font-size: 10px;line-height: 2;" :plain="true" :disabled="disabled_boolean" hover-class="is-hover">
  127. custom-btn
  128. </button>
  129. </view>
  130. <view class="container">
  131. <button style="margin: 10px;
  132. font-size: 15px;color: red;" type="warn" plain="true" :disabled="disabled_boolean">
  133. custom-btn-plain-warn
  134. </button>
  135. </view>
  136. <view class="content">
  137. <button style="margin: 10px;" type="primary" size="default" :disabled="disabled_boolean"
  138. hover-class="none">hover-class none</button>
  139. </view>
  140. <view class="content">
  141. <button style="margin: 10px;" type="primary" size="default" :disabled="disabled_boolean">uni-app x</button>
  142. <button style="margin: 10px;" type="primary"
  143. @tap="change_disabled_boolean(!disabled_boolean)">修改disabled为{{!disabled_boolean}}</button>
  144. </view>
  145. <!--disable-->
  146. <view class="container">
  147. <button style="margin: 10px;" :disabled="false" :size="size_enum[size_enum_current].name"
  148. :type="type_enum[type_enum_current].name" :plain="plain_boolean" @click="button_click"
  149. @touchstart="button_touchstart" @touchmove="button_touchmove" @touchcancel="button_touchcancel"
  150. @touchend="button_touchend" @tap="button_tap" @longpress="button_longpress" class="btn"
  151. :class="default_style ? 'custom-btn' : ''" >
  152. disable-false
  153. </button>
  154. </view>
  155. <view class="container">
  156. <button style="margin: 10px;" :disabled="true" :size="size_enum[size_enum_current].name"
  157. :type="type_enum[type_enum_current].name" :plain="plain_boolean" @click="button_click"
  158. @touchstart="button_touchstart" @touchmove="button_touchmove" @touchcancel="button_touchcancel"
  159. @touchend="button_touchend" @tap="button_tap" @longpress="button_longpress" class="btn"
  160. :class="default_style ? 'custom-btn' : ''" >
  161. disable-true
  162. </button>
  163. </view>
  164. <!-- #ifdef APP -->
  165. </scroll-view>
  166. <!-- #endif -->
  167. </template>
  168. <style>
  169. .main {
  170. padding: 5px 0;
  171. border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  172. flex-direction: column;
  173. justify-content: center;
  174. }
  175. .main .list-item {
  176. width: 100%;
  177. height: 100px;
  178. border: 1px solid #666;
  179. }
  180. .custom-btn {
  181. color: #ffffff;
  182. background-color: #1AAD19;
  183. border-color: #1AAD19;
  184. border-radius: 5px;
  185. border-width: 0.5px;
  186. height: 53px;
  187. }
  188. .is-hover {
  189. color: rgba(255, 255, 255, 0.6);
  190. background-color: rgba(26, 173, 25, 0.7);
  191. border-color: rgba(26, 173, 25, 0.7);
  192. }
  193. .container {
  194. width: 100%;
  195. }
  196. .is-hover {
  197. color: rgba(255, 255, 255, 0.6);
  198. background-color: #179b16;
  199. border-color: #179b16;
  200. }
  201. </style>