index.vue 2.1 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-loading :mode="mode" :show="show" :color="color" :size="size"></u-loading>
  7. </view>
  8. </view>
  9. <view class="u-config-wrap">
  10. <view class="u-config-title u-border-bottom">
  11. 参数配置
  12. </view>
  13. <view class="u-config-item">
  14. <view class="u-item-title">模式</view>
  15. <u-subsection :list="['圆圈', '花朵']" @change="modeChange"></u-subsection>
  16. </view>
  17. <view class="u-config-item">
  18. <view class="u-item-title">颜色(只对圆圈模式有效)</view>
  19. <u-subsection :list="['default', 'primary', 'error', 'warning', 'success']" @change="colorChange"></u-subsection>
  20. </view>
  21. <view class="u-config-item">
  22. <view class="u-item-title">尺寸(单位rpx)</view>
  23. <u-subsection current="1" :list="['28', '34', '40']" @change="sizeChange"></u-subsection>
  24. </view>
  25. <view class="u-config-item">
  26. <view class="u-item-title">是否显示</view>
  27. <u-subsection current="1" :list="['否', '是']" @change="showChange"></u-subsection>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. mode: 'circle',
  37. color: '#c7c7c7',
  38. size: '34',
  39. show: true
  40. }
  41. },
  42. methods: {
  43. modeChange(index) {
  44. this.mode = index == 0 ? 'circle' : 'flower';
  45. },
  46. colorChange(index) {
  47. if(index == 0) {
  48. this.color = '#c7c7c7';
  49. } else {
  50. let color = index == 1 ? 'primary' : index == 2 ? 'error' : index == 3 ? 'warning' : 'success';
  51. this.color = this.$u.color[color];
  52. }
  53. },
  54. sizeChange(index) {
  55. this.size = index == 0 ? '28' : index == 1 ? '34' : '40';
  56. },
  57. showChange(index) {
  58. // 两个!!可以把0变成false,1变成true
  59. this.show = !!index;
  60. },
  61. // 选中某个复选框时,由checkbox时触发
  62. checkboxChange(e) {
  63. //console.log(e);
  64. },
  65. // 选中任一checkbox时,由checkbox-group触发
  66. checkboxGroupChange(e) {
  67. this.result = e;
  68. // console.log(this.result);
  69. }
  70. }
  71. }
  72. </script>
  73. <style scoped lang="scss">
  74. .u-demo {}
  75. </style>