index.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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-number-box v-model="value" :bg-color="bgColor" :color="color" :min="0"
  7. :step="step" :disabled="disabled" @change="change" @focus="focus"></u-number-box>
  8. </view>
  9. </view>
  10. <view class="u-config-wrap">
  11. <view class="u-config-title u-border-bottom">
  12. 参数配置
  13. </view>
  14. <view class="u-config-item">
  15. <view class="u-item-title">初始值</view>
  16. <u-subsection :list="[1, 5, 18]" @change="valueChange"></u-subsection>
  17. </view>
  18. <view class="u-config-item">
  19. <view class="u-item-title">自定义样式</view>
  20. <u-subsection current="1" :list="['是', '否']" @change="styleChange"></u-subsection>
  21. </view>
  22. <view class="u-config-item">
  23. <view class="u-item-title">是否禁用</view>
  24. <u-subsection current="1" :list="['是', '否']" @change="disabledChange"></u-subsection>
  25. </view>
  26. <view class="u-config-item">
  27. <view class="u-item-title">步进值</view>
  28. <u-subsection :list="[1, 3, 5, 8]" @change="stepChange"></u-subsection>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. value: 1,
  38. bgColor: "#F2F3F5",
  39. color: '#323233',
  40. disabled: false,
  41. step: 1,
  42. };
  43. },
  44. methods: {
  45. valueChange(index) {
  46. this.value = index == 0 ? 1 : index == 1 ? 5 : 18;
  47. },
  48. styleChange(index) {
  49. if(index == 0) {
  50. this.bgColor = '#ff6d00';
  51. this.color = '#fff';
  52. } else {
  53. this.bgColor = "#F2F3F5";
  54. this.color = '#323233';
  55. }
  56. },
  57. disabledChange(index) {
  58. this.disabled = index == 0 ? true : false;
  59. },
  60. stepChange(index) {
  61. this.step = index == 0 ? 1 : index == 1 ? 3 : index == 2 ? 5 : 8;
  62. },
  63. change(e) {
  64. //console.log(e.value);
  65. },
  66. focus() {
  67. console.log('focus');
  68. }
  69. }
  70. };
  71. </script>
  72. <style lang="scss" scoped>
  73. .u-demo {}
  74. </style>