index.vue 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view class="u-demo">
  3. <view class="u-demo-wrap">
  4. <view class="u-demo-title">演示效果</view>
  5. <view class="u-demo-area">
  6. <u-toast ref="uToast"></u-toast>
  7. <u-message-input :mode="mode" :maxlength="maxlength" :value="value"
  8. :breathe="breathe" :bold="bold" @finish="finish" :dot-fill="dotFill"></u-message-input>
  9. </view>
  10. </view>
  11. <view class="u-config-wrap">
  12. <view class="u-config-title u-border-bottom">
  13. 参数配置
  14. </view>
  15. <view class="u-config-item">
  16. <view class="u-item-title">模式选择</view>
  17. <u-subsection :list="['方框', '下划线', '中划线']" @change="modeChange"></u-subsection>
  18. </view>
  19. <view class="u-config-item">
  20. <view class="u-item-title">输入长度</view>
  21. <u-subsection :list="[4, 5, 6]" @change="maxLengthChange"></u-subsection>
  22. </view>
  23. <view class="u-config-item">
  24. <!-- #ifdef MP-WEIXIN -->
  25. <view class="u-item-title">初始值(为满足演示需要,微信小程序切换会有抖动,非性能问题)</view>
  26. <!-- #endif -->
  27. <!-- #ifndef MP-WEIXIN -->
  28. <view class="u-item-title">初始值</view>
  29. <!-- #endif -->
  30. <u-subsection :list="['空', '23', '678']" @change="valueChange"></u-subsection>
  31. </view>
  32. <view class="u-config-item">
  33. <view class="u-item-title">呼吸灯效果</view>
  34. <u-subsection :list="['是', '否']" @change="breatheChange"></u-subsection>
  35. </view>
  36. <view class="u-config-item">
  37. <view class="u-item-title">是否加粗</view>
  38. <u-subsection :list="['是', '否']" @change="boldChange"></u-subsection>
  39. </view>
  40. <view class="u-config-item">
  41. <view class="u-item-title">点替代输入值</view>
  42. <u-subsection current="1" :list="['是', '否']" @change="dotFillChange"></u-subsection>
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data() {
  50. return {
  51. mode: 'box',
  52. maxlength: 4,
  53. value: '',
  54. bold: true,
  55. breathe: true,
  56. dotFill: false,
  57. }
  58. },
  59. computed: {
  60. },
  61. onLoad() {
  62. },
  63. methods: {
  64. modeChange(index) {
  65. this.mode = index == 0 ? 'box' : index == 1 ? 'bottomLine' : 'middleLine';
  66. },
  67. maxLengthChange(index) {
  68. this.maxlength = index == 0 ? 4 : index == 1 ? 5 : 6;
  69. },
  70. valueChange(index) {
  71. this.value = index == 0 ? '' : index == 1 ? '23' : '678';
  72. },
  73. breatheChange(index) {
  74. this.breathe = index == 0 ? true : false;
  75. },
  76. boldChange(index) {
  77. this.bold = index == 0 ? true : false;
  78. },
  79. dotFillChange(index) {
  80. this.dotFill = index == 0 ? true : false;
  81. },
  82. finish(value) {
  83. this.$refs.uToast.show({
  84. title: '输入完成,值为:' + value,
  85. type: 'success'
  86. })
  87. }
  88. }
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. .u-demo {}
  93. </style>