index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <!--
  2. * @Desc: --- ----
  3. * @Date: 2020-04-22 12:29:21
  4. * @LastEditors: 王
  5. * @LastEditTime: 2020-04-22 18:33:28
  6. -->
  7. <template>
  8. <view class="u-demo">
  9. <view class="u-demo-wrap">
  10. <view class="u-demo-title">演示效果</view>
  11. <view class="u-demo-area">
  12. <u-gap :bg-color="bgColor" :height="height" :margin-top="marginTop" :margin-bottom="marginBottom"></u-gap>
  13. </view>
  14. </view>
  15. <view class="u-config-wrap">
  16. <view class="u-config-title u-border-bottom">参数配置</view>
  17. <view class="u-config-item">
  18. <view class="u-item-title">背景颜色</view>
  19. <u-subsection :list="['default', 'primary', 'error', 'warning', 'success']" @change="bgColorChange"></u-subsection>
  20. </view>
  21. <view class="u-config-item">
  22. <view class="u-item-title">高度</view>
  23. <u-subsection :list="['30', '50', '70']" @change="heightChange"></u-subsection>
  24. </view>
  25. <view class="u-config-item">
  26. <view class="u-item-title">上下外边距</view>
  27. <u-subsection :list="['30', '50', '70']" @change="marginChange"></u-subsection>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. height: 30,
  37. bgColor: this.$u.color.bgColor,
  38. marginTop: 30,
  39. marginBottom: 30
  40. };
  41. },
  42. methods: {
  43. bgColorChange(index) {
  44. let color = index == 0 ? 'default' : index == 1 ? 'primary' : index == 2 ? 'error' : index == 3 ? 'warning' : 'success';
  45. this.bgColor = color == 'default' ? this.$u.color['bgColor'] : this.$u.color[color];
  46. },
  47. heightChange(index) {
  48. this.height = index == 0 ? 30 : index == 1 ? 50 : 70;
  49. },
  50. marginChange(index) {
  51. this.marginTop = ['30', '50', '70'][index];
  52. this.marginBottom = this.marginTop;
  53. }
  54. }
  55. };
  56. </script>
  57. <style lang="scss" scoped>
  58. .wrap {
  59. padding: 24rpx;
  60. }
  61. </style>