index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <view class="u-demo">
  3. <view class="u-demo-wrap" style="padding-left:0;padding-right:0;margin-left: -40rpx;margin-right: -40rpx;">
  4. <view class="u-demo-title">演示效果</view>
  5. <view class="u-demo-area">
  6. <u-cell-group title="读万卷书">
  7. <u-cell-item center :is-link="true" :label="label" value="铁马冰河入梦来" i ndex="index" @click="click" :hover-class="hoverClass"
  8. :arrow="arrow" :title="title" :icon="icon">
  9. <u-badge :absolute="false" v-if="rightSlot == 'badge'" count="105" slot="right-icon"></u-badge>
  10. <u-switch v-if="rightSlot == 'switch'" slot="right-icon" v-model="checked"></u-switch>
  11. </u-cell-item>
  12. <u-cell-item :border-bottom="false" value="" title="铁马冰河入梦来" value="行万里路" :arrow="false">
  13. <u-icon slot="icon" size="34" name="calendar" style="margin-right: 5px;"></u-icon>
  14. <u-icon slot="right-icon" size="34" name="calendar"></u-icon>
  15. <u-field slot="value"></u-field>
  16. </u-cell-item>
  17. </u-cell-group>
  18. </view>
  19. </view>
  20. <view class="u-config-wrap">
  21. <view class="u-config-title u-border-bottom">
  22. 参数配置
  23. </view>
  24. <view class="u-config-item">
  25. <view class="u-item-title">更换图标</view>
  26. <u-subsection :list="['是', '否']" @change="iconChange"></u-subsection>
  27. </view>
  28. <!-- 小程序无法动态切换slot -->
  29. <!-- #ifndef MP -->
  30. <view class="u-config-item">
  31. <view class="u-item-title">自定义右侧内容</view>
  32. <u-subsection :list="['文字', 'Switch组件', 'Badge组件']" @change="rightSlotChange"></u-subsection>
  33. </view>
  34. <!-- #endif -->
  35. <view class="u-config-item">
  36. <view class="u-item-title">描述信息</view>
  37. <u-subsection current="1" :list="['是', '否']" @change="lableChange"></u-subsection>
  38. </view>
  39. <view class="u-config-item">
  40. <view class="u-item-title">更换标题</view>
  41. <u-subsection :list="['是', '否']" @change="titleChange"></u-subsection>
  42. </view>
  43. <view class="u-config-item">
  44. <view class="u-item-title">右侧箭头</view>
  45. <u-subsection :list="['是', '否']" @change="arrowChange"></u-subsection>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data() {
  53. return {
  54. icon: 'setting',
  55. arrow: true,
  56. label: '',
  57. title: '青山一道同云雨',
  58. rightSlot: true,
  59. checked: false,
  60. }
  61. },
  62. computed: {
  63. hoverClass() {
  64. // 如果右侧是switch步进器组件的话,去掉cell的点击反馈,因为这个时候点击的反馈应该在switch上
  65. return this.rightSlot == 'switch' ? 'none' : 'u-cell-hover';
  66. }
  67. },
  68. methods: {
  69. iconChange(index) {
  70. this.icon = index == 0 ? 'setting' : 'file-text'
  71. },
  72. arrowChange(index) {
  73. this.arrow = index == 0 ? true : false
  74. },
  75. lableChange(index) {
  76. this.label = index == 0 ? '岂曰无衣,与子同裳' : ''
  77. },
  78. titleChange(index) {
  79. this.title = index == 0 ? '青山一道同云雨' : '明月何曾是两乡'
  80. },
  81. rightSlotChange(index) {
  82. this.rightSlot = index == 0 ? 'text' : index == 1 ? 'switch' : 'badge'
  83. if (index == 0) this.arrow = true;
  84. else this.arrow = false;
  85. },
  86. click(index) {
  87. // console.log(index);
  88. }
  89. }
  90. };
  91. </script>
  92. <style lang="scss" scoped>
  93. .gab {
  94. background-color: rgb(245, 245, 245);
  95. height: 20rpx;
  96. }
  97. .wrap {
  98. height: 100vh;
  99. background-color: rgb(241, 241, 241);
  100. }
  101. .box {
  102. padding: 30rpx 00rpx;
  103. font-size: 28rpx;
  104. color: $u-type-info;
  105. display: flex;
  106. align-items: center;
  107. justify-content: space-between;
  108. }
  109. </style>