layout.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-gradual-blue" :isBack="true"><block slot="backText">返回</block><block slot="content">布局</block></cu-custom>
  4. <scroll-view scroll-x class="bg-white nav text-center fixed" :style="[{top:CustomBar + 'px'}]">
  5. <view class="cu-item" :class="index==TabCur?'text-blue cur':''" v-for="(item,index) in tabNav" :key="index" @tap="tabSelect"
  6. :data-id="index">
  7. {{tabNav[index]}}
  8. </view>
  9. </scroll-view>
  10. <block v-if="TabCur==0">
  11. <view class="cu-bar bg-white solid-bottom margin-top">
  12. <view class="action">
  13. <text class="cuIcon-title text-blue"></text>固定尺寸
  14. </view>
  15. </view>
  16. <view class="padding bg-white">
  17. <view class="flex flex-wrap">
  18. <view class="basis-xs bg-grey margin-xs padding-sm radius">xs(20%)</view>
  19. <view class="basis-df"></view>
  20. <view class="basis-sm bg-grey margin-xs padding-sm radius">sm(40%)</view>
  21. <view class="basis-df"></view>
  22. <view class="basis-df bg-grey margin-xs padding-sm radius">sub(50%)</view>
  23. <view class="basis-lg bg-grey margin-xs padding-sm radius">lg(60%)</view>
  24. <view class="basis-xl bg-grey margin-xs padding-sm radius">xl(80%)</view>
  25. </view>
  26. </view>
  27. <view class="cu-bar bg-white margin-top solid-bottom">
  28. <view class="action">
  29. <text class="cuIcon-title text-blue"></text>比例布局
  30. </view>
  31. </view>
  32. <view class="padding bg-white">
  33. <view class="flex">
  34. <view class="flex-sub bg-grey padding-sm margin-xs radius">1</view>
  35. <view class="flex-sub bg-grey padding-sm margin-xs radius">1</view>
  36. </view>
  37. <view class="flex p-xs margin-bottom-sm mb-sm">
  38. <view class="flex-sub bg-grey padding-sm margin-xs radius">1</view>
  39. <view class="flex-twice bg-grey padding-sm margin-xs radius">2</view>
  40. </view>
  41. <view class="flex p-xs margin-bottom-sm mb-sm">
  42. <view class="flex-sub bg-grey padding-sm margin-xs radius">1</view>
  43. <view class="flex-twice bg-grey padding-sm margin-xs radius">2</view>
  44. <view class="flex-treble bg-grey padding-sm margin-xs radius">3</view>
  45. </view>
  46. </view>
  47. <view class="cu-bar bg-white margin-top solid-bottom">
  48. <view class="action">
  49. <text class="cuIcon-title text-blue"></text>水平对齐(justify)
  50. </view>
  51. </view>
  52. <view class="bg-white">
  53. <view class="flex solid-bottom padding justify-start">
  54. <view class="bg-grey padding-sm margin-xs radius">start</view>
  55. <view class="bg-grey padding-sm margin-xs radius">start</view>
  56. </view>
  57. <view class="flex solid-bottom padding justify-end">
  58. <view class="bg-grey padding-sm margin-xs radius">end</view>
  59. <view class="bg-grey padding-sm margin-xs radius">end</view>
  60. </view>
  61. <view class="flex solid-bottom padding justify-center">
  62. <view class="bg-grey padding-sm margin-xs radius">center</view>
  63. <view class="bg-grey padding-sm margin-xs radius">center</view>
  64. </view>
  65. <view class="flex solid-bottom padding justify-between">
  66. <view class="bg-grey padding-sm margin-xs radius">between</view>
  67. <view class="bg-grey padding-sm margin-xs radius">between</view>
  68. </view>
  69. <view class="flex solid-bottom padding justify-around">
  70. <view class="bg-grey padding-sm margin-xs radius">around</view>
  71. <view class="bg-grey padding-sm margin-xs radius">around</view>
  72. </view>
  73. </view>
  74. <view class="cu-bar bg-white margin-top solid-bottom">
  75. <view class="action">
  76. <text class="cuIcon-title text-blue"></text>垂直对齐(align)
  77. </view>
  78. </view>
  79. <view class="bg-white">
  80. <view class="flex solid-bottom padding align-start">
  81. <view class="bg-grey padding-lg margin-xs radius">ColorUi</view>
  82. <view class="bg-grey padding-sm margin-xs radius">start</view>
  83. </view>
  84. <view class="flex solid-bottom padding align-end">
  85. <view class="bg-grey padding-lg margin-xs radius">ColorUi</view>
  86. <view class="bg-grey padding-sm margin-xs radius">end</view>
  87. </view>
  88. <view class="flex solid-bottom padding align-center">
  89. <view class="bg-grey padding-lg margin-xs radius">ColorUi</view>
  90. <view class="bg-grey padding-sm margin-xs radius">center</view>
  91. </view>
  92. </view>
  93. </block>
  94. <block v-if="TabCur==1">
  95. <view class="cu-bar bg-white margin-top solid-bottom">
  96. <view class="action">
  97. <text class="cuIcon-title text-blue"></text>等分列
  98. </view>
  99. <view class="action"></view>
  100. </view>
  101. <view class="bg-white padding">
  102. <view class="grid margin-bottom text-center" v-for="(item,index) in 5" :key="index" :class="'col-' + (index+1)">
  103. <view class="padding" :class="indexs%2==0?'bg-cyan':'bg-blue'" v-for="(item,indexs) in (index+1)*2" :key="indexs">{{indexs+1}}</view>
  104. </view>
  105. </view>
  106. <view class="cu-bar bg-white margin-top solid-bottom">
  107. <view class="action">
  108. <text class="cuIcon-title text-blue"></text>等高
  109. </view>
  110. <view class="action"></view>
  111. </view>
  112. <view class="bg-white padding">
  113. <view class="grid col-4 grid-square">
  114. <view class="bg-img" v-for="(item,index) in avatar" :key="index" :style="[{ backgroundImage:'url(' + avatar[index] + ')' }]"></view>
  115. </view>
  116. </view>
  117. </block>
  118. <block v-if="TabCur==2">
  119. <view class="cu-bar bg-white margin-top solid-bottom">
  120. <view class="action">
  121. <text class="cuIcon-title text-blue"></text>浮动
  122. </view>
  123. </view>
  124. <view class="bg-white padding">
  125. <view class=" cf padding-sm">
  126. <view class="bg-grey radius fl padding-sm">ColorUi fl</view>
  127. <view class="bg-grey radius fr padding-sm">ColorUi fr</view>
  128. </view>
  129. </view>
  130. <view class="cu-bar bg-white solid-bottom margin-top solid-bottom">
  131. <view class="action">
  132. <text class="cuIcon-title text-blue"></text>内外边距
  133. </view>
  134. </view>
  135. <view class="bg-white">
  136. <view class="padding bg-gray">{size}的尺寸有xs/sm/df/lg/xl</view>
  137. <view class="flex flex-wrap padding solid-top">
  138. <view class="basis-df padding-bottom-xs">外边距</view>
  139. <view class="basis-df padding-bottom-xs">内边距</view>
  140. <view class="basis-df">.margin-{size}</view>
  141. <view class="basis-df">.padding-{size}</view>
  142. </view>
  143. <view class="flex flex-wrap padding solid-top">
  144. <view class="basis-df padding-bottom-xs">水平方向外边距</view>
  145. <view class="basis-df padding-bottom-xs">水平方向内边距</view>
  146. <view class="basis-df">.margin-lr-{size}</view>
  147. <view class="basis-df">.padding-lr-{size}</view>
  148. </view>
  149. <view class="flex flex-wrap padding solid-top">
  150. <view class="basis-df padding-bottom-xs">垂直方向外边距</view>
  151. <view class="basis-df padding-bottom-xs">垂直方向内边距</view>
  152. <view class="basis-df">.margin-tb-{size}</view>
  153. <view class="basis-df">.padding-tb-{size}</view>
  154. </view>
  155. <view class="flex flex-wrap padding solid-top">
  156. <view class="basis-df padding-bottom-xs">上外边距</view>
  157. <view class="basis-df padding-bottom-xs">上内边距</view>
  158. <view class="basis-df">.margin-top-{size}</view>
  159. <view class="basis-df">.padding-top-{size}</view>
  160. </view>
  161. <view class="flex flex-wrap padding solid-top">
  162. <view class="basis-df padding-bottom-xs">右外边距</view>
  163. <view class="basis-df padding-bottom-xs">右内边距</view>
  164. <view class="basis-df">.margin-right-{size}</view>
  165. <view class="basis-df">.padding-right-{size}</view>
  166. </view>
  167. <view class="flex flex-wrap padding solid-top">
  168. <view class="basis-df padding-bottom-xs">下外边距</view>
  169. <view class="basis-df padding-bottom-xs">下内边距</view>
  170. <view class="basis-df">margin-bottom-{size}</view>
  171. <view class="basis-df">.padding-bottom-{size}</view>
  172. </view>
  173. <view class="flex flex-wrap padding solid-top">
  174. <view class="basis-df padding-bottom-xs">左外边距</view>
  175. <view class="basis-df padding-bottom-xs">左内边距</view>
  176. <view class="basis-df">.margin-left-{size}</view>
  177. <view class="basis-df">.padding-left-{size}</view>
  178. </view>
  179. </view>
  180. </block>
  181. </view>
  182. </template>
  183. <script>
  184. export default {
  185. data() {
  186. return {
  187. CustomBar: this.CustomBar,
  188. TabCur: 0,
  189. avatar:['https://ossweb-img.qq.com/images/lol/web201310/skin/big10001.jpg','https://ossweb-img.qq.com/images/lol/web201310/skin/big81005.jpg','https://ossweb-img.qq.com/images/lol/web201310/skin/big25002.jpg','https://ossweb-img.qq.com/images/lol/web201310/skin/big99008.jpg'],
  190. tabNav: ['Flex布局', 'Grid布局', '辅助布局']
  191. };
  192. },
  193. methods: {
  194. tabSelect(e) {
  195. this.TabCur = e.currentTarget.dataset.id;
  196. this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
  197. }
  198. }
  199. }
  200. </script>
  201. <style>
  202. page {
  203. padding-top: 45px;
  204. }
  205. </style>