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