123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <template >
- <view class="tm-col" :class="[widths?'':'tm-col-'+grid, 'ma-' + margin,'mb-'+bma[1],'mx-'+bma[0]]"
- :style="{
- width:widths,
- order: order,
- verticalAlign: align,
-
- }">
-
- <view class="tm-col-body " @click="click" :style="{
- textAlign:justify
- }" :class="['pa-' + padding, aligns,` ${customClass} `,'round-'+round,color]"><slot></slot></view>
- </view>
- </template>
- <script>
-
- export default {
- props: {
-
- customClass: {
- type: String,
- default: ''
- },
-
- round: {
- type: String|Number,
- default: '0'
- },
-
- color: {
- type: String,
- default: ''
- },
-
- width: {
- type: String | Number,
- default: ''
- },
-
- grid: {
- type: String | Number,
- default: 1
- },
-
- padding: {
- type: String | Number,
- default: '0'
- },
-
- margin: {
- type: String | Number,
- default: '0'
- },
-
- justify:{
- type:String,
- default:'center'
- },
-
- align:{
- type:String,
- default:'top'
- },
-
- order: {
- type: String | Number,
- default: '0'
- },
- maxCol:{
- type:Number,
- default:12
- }
- },
- data() {
- return {
-
- widths:'',
- bma:[0,0],
-
- };
- },
- computed: {
- maxCol_count:function() {
- return this.maxCol||12;
- },
- aligns: function() {
- if(this.justify == 'left') return 'flex-start';
- if(this.justify == 'right') return 'flex-end';
- if(this.justify == 'center') return 'flex-center';
- },
- },
- async mounted() {
- let pd = this.$tm.getParentAttr("tm-row",'gutter',this.$parent);
- if(pd) this.bma = pd;
- this.$nextTick(function(){
- this.c_width();
- })
- },
- methods: {
- click(e){
- this.$emit('click',e);
- },
- c_width() {
- let t = this;
-
- if (t.width.indexOf('%') > -1 || t.width.indexOf('vw') > -1 || t.width.indexOf('vh') > -1) {
- t.widths = t.width;
- return ;
- }
- if (t.width === 'auto') {
- t.widths = "100%";
- return;
- }
- if (!isNaN(parseFloat(t.width))) {
- t.widths = uni.upx2px(parseInt(t.width)) + 'px';
- return ;
- }
-
- t.widths = (parseInt(t.grid) / t.maxCol_count) * 100 + '%';
-
- }
- },
- };
- </script>
- <style lang="scss" scoped>
- .tm-col{
- height: inherit;
- display: inline-block;
-
- // #ifndef H5
- height: 100%;
- // #endif
-
-
- .tm-col-body{
- display: block;
-
- }
- }
- </style>
|