Layout 布局

使用指南

在 page.json 中引入组件

  1. "usingComponents": {
  2. "w-row": "wuss-weapp/w-row/index",
  3. "w-col": "wuss-weapp/w-col/index",
  4. }

图片演示

Layout 栅格 - 图1

代码演示

  1. <w-pane title="Layout" desc="布局" />
  2. <w-pane desc="Default" />
  3. <view style="margin: 30px 0;">
  4. <w-row>
  5. <block wx:for="{{ 4 }}" wx:key="index">
  6. <w-col span="6">
  7. <view style="padding: 10px 0;font-size:14px;text-align:center;background: rgba(85,178,240,{{ index%2 == 0 ? .8 : .6 }});">
  8. span[6]
  9. </view>
  10. </w-col>
  11. </block>
  12. </w-row>
  13. </view>
  14. <view style="margin: 30px 0;">
  15. <w-row>
  16. <block wx:for="{{ 3 }}" wx:key="index">
  17. <w-col span="8">
  18. <view style="padding: 10px 0;font-size:14px;text-align:center;background: rgba(85,178,240,{{ index%2 == 0 ? .8 : .6 }});">
  19. span[8]
  20. </view>
  21. </w-col>
  22. </block>
  23. </w-row>
  24. </view>
  25. <view style="margin: 30px 0;">
  26. <w-row>
  27. <block wx:for="{{ 24 }}" wx:key="index">
  28. <w-col span="1">
  29. <view class="w-layout-col" style="padding: 15px 0;font-size:14px;text-align:center;background: rgba(85,178,240,{{ index%2 == 0 ? .8 : .6 }});">
  30. <view style="letter-spacing:0;font-size: 16rpx;">
  31. {{ index+1 }}
  32. </view>
  33. </view>
  34. </w-col>
  35. </block>
  36. </w-row>
  37. </view>
  38. <w-pane desc="Gutter" />
  39. <view style="margin: 30px 0;">
  40. <w-row gutter="10">
  41. <block wx:for="{{ 4 }}" wx:key="index">
  42. <w-col span="6">
  43. <view style="padding: 10px 0;font-size:14px;text-align:center;background: rgba(85,178,240,{{ index%2 == 0 ? .8 : .6 }});">
  44. gutter[10]
  45. </view>
  46. </w-col>
  47. </block>
  48. </w-row>
  49. </view>
  50. <w-pane desc="Direction" />
  51. <view style="margin: 30px 0;">
  52. <w-row direction="right">
  53. <block wx:for="{{ 2 }}" wx:key="index">
  54. <w-col span="6">
  55. <view style="padding: 10px 0;font-size:12px;text-align:center;background: rgba(85,178,240,{{ index%2 == 0 ? .8 : .6 }});">
  56. dirction[right]
  57. </view>
  58. </w-col>
  59. </block>
  60. </w-row>
  61. </view>
  62. <w-pane desc="Offset" />
  63. <view style="margin: 30px 0;">
  64. <w-row>
  65. <block wx:for="{{ 2 }}" wx:key="index">
  66. <w-col span="6" offset="2">
  67. <view style="padding: 10px 0;font-size:12px;text-align:center;background: rgba(85,178,240,{{ index%2 == 0 ? .8 : .6 }});">
  68. offset[2]
  69. </view>
  70. </w-col>
  71. </block>
  72. </w-row>
  73. </view>
  74. <w-pane desc="Push" />
  75. <view style="margin: 30px 0;">
  76. <w-row>
  77. <block wx:for="{{ 2 }}" wx:key="index">
  78. <w-col span="6" push="4">
  79. <view style="padding: 10px 0;font-size:12px;text-align:center;background: rgba(85,178,240,{{ index%2 == 0 ? .8 : .6 }});">
  80. push[4]
  81. </view>
  82. </w-col>
  83. </block>
  84. </w-row>
  85. </view>
  86. <w-pane desc="Pull" />
  87. <view style="margin: 30px 0;">
  88. <w-row direction="right">
  89. <block wx:for="{{ 3 }}" wx:key="index">
  90. <w-col span="6" pull="2">
  91. <view style="padding: 10px 0;font-size:12px;text-align:center;background: rgba(85,178,240,{{ index%2 == 0 ? .8 : .6 }});">
  92. pull[2]
  93. </view>
  94. </w-col>
  95. </block>
  96. </w-row>
  97. </view>
  1. .w-layout-col::before {
  2. content: '';
  3. display: table;
  4. clear: both;
  5. overflow: hidden;
  6. }

API

Attribute 属性

Col
属性说明类型默认值
offset栅格左侧的间隔格数,间隔内不可以有栅格number0
pull栅格向左移动格数number0
push栅格向右移动格数number0
span栅格占位格数,为 0 时相当于 display: nonenumber0
Row
属性说明类型默认值
gutter栅格间隔number0
direction布局排列方式:[left/right]stringleft

Event 事件

事件名说明参数

Slot 插槽

名称说明

Class 自定义类名

类名说明
wuss-class根节点样式类