index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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-divider :type="type" :borderColor="borderColor" :bg-color="bgColor" @click="click"
  7. :half-width="halfWidth" :color="color" :font-size="fontSize">{{text}}</u-divider>
  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="['没有更多了', '到底了']" @change="textChange"></u-subsection>
  17. </view>
  18. <view class="u-config-item">
  19. <view class="u-item-title">单边线宽</view>
  20. <u-subsection current="1" :list="['50', '150', '250']" @change="halfWidthChange"></u-subsection>
  21. </view>
  22. <view class="u-config-item">
  23. <view class="u-item-title">横线颜色</view>
  24. <u-subsection :list="['#dcdfe6', 'primary', 'error', 'warning', 'success']" @change="borderColorChange"></u-subsection>
  25. </view>
  26. <view class="u-config-item">
  27. <view class="u-item-title">内容样式</view>
  28. <u-subsection :list="['默认', '自定义']" @change="contentChange"></u-subsection>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. text: '没有更多了',
  38. bgColor: '#fafafa',
  39. halfWidth: 150,
  40. borderColor: '#dcdfe6',
  41. type: 'primary',
  42. color: '#909399',
  43. fontSize: '26'
  44. }
  45. },
  46. methods: {
  47. textChange(index) {
  48. this.text = index == 0 ? '没有更多了' : '到底了';
  49. },
  50. halfWidthChange(index) {
  51. this.halfWidth = index == 0 ? 50 : index == 1 ? 150 : 250;
  52. },
  53. borderColorChange(index) {
  54. if(index == 0) {
  55. this.borderColor = '#dcdfe6';
  56. } else {
  57. // 因为border-color参数优先级高于type,要让type起作用,就需要设置border-color为空
  58. this.borderColor = '';
  59. this.type = index == 1 ? 'primary' : index == 2 ? 'error' : index == 3 ? 'warning' : 'success';
  60. }
  61. },
  62. contentChange(index) {
  63. if(index == 0) {
  64. this.color = '#909399';
  65. this.fontSize = 26;
  66. } else {
  67. this.color = this.$u.color['primary'];
  68. this.fontSize = 30;
  69. }
  70. },
  71. click() {
  72. console.log('click');
  73. }
  74. }
  75. }
  76. </script>
  77. <style scoped lang="scss">
  78. .u-demo {}
  79. </style>