radius.nvue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="container">
  3. <uni-card :is-shadow="false" is-full>
  4. <view class="header"><text class="uni-h6">使用边框半径辅助样式对元素快速应用</text> <text
  5. class="uni-primary uni-px-3 uni-h6">border-radius</text> <text class="uni-h6">样式。</text></view>
  6. <view class="uni-mt-5 header" ><text class="uni-h6">规则为</text> <text
  7. class="uni-primary uni-pl-3 uni-h6">uni-radius-${direction}-${size}</text></view>
  8. <view class="uni-mt-5 header"><text class="uni-h6">如果需要四边,则不需要指定</text> <text class="uni-primary uni-pl-3 uni-h6">direction</text></view>
  9. <view class="uni-mt-5"><text class="uni-h6">各值的含义请参考文档</text></view>
  10. </uni-card>
  11. <uni-section title="效果展示" type="line">
  12. <view class="margin">
  13. <view class="box uni-primary-bg uni-ma-5" :class="[radiusClass]">
  14. <text class="uni-white">通过下面的选项控制圆角</text>
  15. </view>
  16. </view>
  17. <view class="actions uni-mt-10">
  18. <text class="action-label">位置</text>
  19. <uni-data-checkbox v-model="formData.direction" multiple :localdata="directionData"
  20. @change="change($event,1)"></uni-data-checkbox>
  21. </view>
  22. <view class="actions uni-mt-3 uni-mb-10">
  23. <text class="action-label">大小</text>
  24. <uni-data-checkbox v-model="formData.size" :localdata="sizeData" @change="change($event,2)">
  25. </uni-data-checkbox>
  26. </view>
  27. </uni-section>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. radiusClass: 'uni-radius-lg',
  35. formData: {
  36. direction: ['t', 'b'],
  37. size: 'lg'
  38. },
  39. directionData: [{
  40. value: 't',
  41. text: '左上+右上'
  42. }, {
  43. value: 'r',
  44. text: '右上+右下'
  45. }, {
  46. value: 'b',
  47. text: '左下+右下'
  48. }, {
  49. value: 'l',
  50. text: '右上+左下'
  51. }, {
  52. value: 'tl',
  53. text: '左上'
  54. }, {
  55. value: 'tr',
  56. text: '右上'
  57. }, {
  58. value: 'bl',
  59. text: '左下'
  60. }, {
  61. value: 'br',
  62. text: '右下'
  63. }],
  64. sizeData: [{
  65. value: '0',
  66. text: '无'
  67. }, {
  68. value: 'sm',
  69. text: '小'
  70. }, {
  71. value: 'lg',
  72. text: '常规'
  73. }, {
  74. value: 'xl',
  75. text: '大'
  76. }, {
  77. value: 'circle',
  78. text: '圆'
  79. }, {
  80. value: 'pill',
  81. text: '最大化'
  82. }]
  83. }
  84. },
  85. onLoad() {},
  86. methods: {
  87. change(e, type) {
  88. let {
  89. direction,
  90. size
  91. } = this.formData
  92. this.radiusClass = ''
  93. direction.forEach(v => {
  94. this.radiusClass += `uni-radius-${v}-${size} `
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style>
  101. .header {
  102. display: flex;
  103. flex-direction: row;
  104. flex-wrap: wrap;
  105. }
  106. .margin {
  107. display: flex;
  108. height: 200px;
  109. margin: 10px;
  110. overflow: hidden;
  111. border-radius: 5px;
  112. border: 1px #eee solid;
  113. /* #ifndef APP-NVUE */
  114. box-sizing: border-box;
  115. /* #endif */
  116. }
  117. .margin-item {
  118. display: flex;
  119. flex: 1;
  120. }
  121. .box {
  122. display: flex;
  123. align-items: center;
  124. justify-content: center;
  125. flex: 1;
  126. }
  127. .actions {
  128. display: flex;
  129. flex-direction: row;
  130. align-items: center;
  131. }
  132. .action-label {
  133. /* #ifndef APP-NVUE */
  134. flex-shrink: 0;
  135. /* #endif */
  136. width: 50px;
  137. margin-left: 10px;
  138. margin-right: 10px;
  139. font-size: 12px;
  140. }
  141. </style>