index.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 u-flex u-row-center">
  6. <!-- 头条小程序因为兼容性,必须要给组件写上u-line类 -->
  7. <u-line class="u-line" :border-style="borderStyle" color="red" :color="color" :length="length" :direction="direction" :hair-line="hairLine"></u-line>
  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="['primary', 'success', 'warning', 'error', 'info']" @change="colorChange"></u-subsection>
  17. </view>
  18. <view class="u-config-item">
  19. <view class="u-item-title">线条类型</view>
  20. <u-subsection :list="['实线', '方形虚线', '圆点虚线']" @change="borderStyleChange"></u-subsection>
  21. </view>
  22. <view class="u-config-item">
  23. <view class="u-item-title">细边</view>
  24. <u-subsection :list="['是', '否']" @change="hairLineChange"></u-subsection>
  25. </view>
  26. <view class="u-config-item">
  27. <view class="u-item-title">方向</view>
  28. <u-subsection :list="['水平', '垂直']" @change="directionChange"></u-subsection>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. direction: 'row',
  38. hairLine: true,
  39. length: '100%',
  40. color: this.$u.color['primary'],
  41. borderStyle: 'solid'
  42. }
  43. },
  44. methods: {
  45. colorChange(index) {
  46. this.color = this.$u.color[['primary', 'success', 'warning', 'error', 'info'][index]];
  47. },
  48. hairLineChange(index) {
  49. this.hairLine = !index;
  50. },
  51. directionChange(index) {
  52. this.direction = index == 0 ? 'row' : 'col';
  53. if(index == 0) this.length = '100%';
  54. else this.length = '50rpx';
  55. },
  56. borderStyleChange(index) {
  57. this.borderStyle = ['solid', 'dashed', 'dotted'][index];
  58. }
  59. }
  60. }
  61. </script>
  62. <style scoped lang="scss">
  63. .u-demo-area {
  64. }
  65. </style>