Skip to content

Commit

Permalink
Grid: add prop:col (airyland#1985)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinHaobin authored and airyland committed Sep 15, 2017
1 parent 442216f commit d8dce35
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/grid/grid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
name: 'grid',
methods: {
countColumn () {
this.column = this.$children.length
this.childrenSize = this.$children.length
}
},
props: {
Expand All @@ -21,11 +21,19 @@ export default {
}
return true
}
},
col: {
type: Number
}
},
computed: {
column () {
return this.col || this.childrenSize
}
},
data () {
return {
column: 3
childrenSize: 3
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/grid/metas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ grid-item:
en: slot for label, the same func as prop:label
zh-CN: label文字的slot,作用同prop:label
changes:
next:
- '[feature] add `col` props'
zh-CN:
- '[feature] 添加 `col` 属性,自定义列数'
v2.6.0:
en:
- '[change] prop:rows is deprecated #1971'
Expand Down
6 changes: 6 additions & 0 deletions src/demos/Grid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<span class="grid-center">{{i}}</span>
</grid-item>
</grid>
<group-title>custom col</group-title>
<grid :col="3">
<grid-item v-for="i in 6" :key="i">
<span class="grid-center">{{i}}</span>
</grid-item>
</grid>
</div>
</template>

Expand Down

0 comments on commit d8dce35

Please sign in to comment.