index.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. <view class="u-badge-wrap"><u-badge :is-center="isCenter" :type="type" :count="count" :is-dot="isDot" :offset="offset" :size="size"></u-badge></view>
  7. </view>
  8. </view>
  9. <view class="u-config-wrap">
  10. <view class="u-config-title u-border-bottom">参数配置</view>
  11. <view class="u-config-item">
  12. <view class="u-item-title">数值显示</view>
  13. <u-subsection current="1" :list="[0, 8, 15, 106, 209]" @change="countChange"></u-subsection>
  14. </view>
  15. <view class="u-config-item">
  16. <view class="u-item-title">主题选择</view>
  17. <u-subsection current="2" :list="['primary', 'success', 'error', 'warning', 'info']" @change="typeChange"></u-subsection>
  18. </view>
  19. <view class="u-config-item">
  20. <view class="u-item-title">显示点</view>
  21. <u-subsection current="1" :list="['是', '否']" @change="isDotChange"></u-subsection>
  22. </view>
  23. <view class="u-config-item">
  24. <view class="u-item-title">尺寸</view>
  25. <u-subsection :list="['default', 'mini']" @change="sizeChange"></u-subsection>
  26. </view>
  27. <view class="u-config-item">
  28. <view class="u-item-title">位置偏移</view>
  29. <u-subsection current="1" :list="['[20, 20]', '[-8, -8]', '[-20, -20]']" @change="offsetChange"></u-subsection>
  30. </view>
  31. <view class="u-config-item">
  32. <view class="u-item-title">中心点与父右上角重合</view>
  33. <u-subsection current="1" :list="['是', '否']" @change="isCenterChange"></u-subsection>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. count: 8,
  43. type: 'error',
  44. isDot: false,
  45. offset: [-8, -8],
  46. size: 'default',
  47. isCenter: false
  48. };
  49. },
  50. methods: {
  51. countChange(index) {
  52. this.count = index == 0 ? 0 : index == 1 ? 8 : index == 2 ? 15 : index == 3 ? 106 : 209;
  53. },
  54. typeChange(index) {
  55. this.type = index == 0 ? 'primary' : index == 1 ? 'success' : index == 2 ? 'error' : index == 3 ? 'warning' : 'info';
  56. },
  57. sizeChange(index) {
  58. this.size = index == 0 ? 'default' : 'mini';
  59. },
  60. isDotChange(index) {
  61. this.isDot = index == 0 ? true : false;
  62. },
  63. offsetChange(index) {
  64. this.offset = index == 0 ? [20, 20] : index == 1 ? [-8, -8] : [-20, -20];
  65. },
  66. isCenterChange(index) {
  67. this.isCenter = index == 0 ? true : false;
  68. }
  69. }
  70. };
  71. </script>
  72. <style lang="scss" scoped>
  73. .u-badge-wrap {
  74. width: 60px;
  75. height: 60px;
  76. border-radius: 6px;
  77. background-color: $u-light-color;
  78. position: relative;
  79. margin: auto;
  80. }
  81. </style>