CSS.uvue 7.1 KB
Newer Older
H
hdx 已提交
1
<template>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
2 3
	<view class="uni-container">
		<view class="uni-header-logo">
DCloud_JSON's avatar
DCloud_JSON 已提交
4
			<image class="uni-header-image" src="/static/cssIndex.png"></image>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
5 6 7
		</view>
		<view class="uni-hello-text">
			<text class="hello-text">uni-app x目前已支持的CSS属性,展示样式仅供参考,文档详见:</text>
8
			<u-link :href="'https://uniapp.dcloud.io/component/'" :text="'https://uniapp.dcloud.io/component/'" :inWhiteList="true"></u-link>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
9 10 11 12
		</view>
		<view class="uni-panel" v-for="(item, index) in list" :key="item.id">
			<view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index, item)">
				<text class="uni-panel-text" :class="item.enable == false ? 'text-disabled' : ''">{{item.name}}</text>
13
				<image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon" class="uni-icon"></image>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
14 15 16
			</view>
			<view class="uni-panel-c" v-if="item.open">
				<view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)">
17
					<text class="uni-navigate-text" :class="page.enable == false ? 'text-disabled' : ''">{{page.name}}</text>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
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
					<image :src="arrowRightIcon" class="uni-icon"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script lang="ts">
	type Page = {
		name : string,
		enable ?: boolean,
		url ?: string
	}
	type ListItem = {
		id : string,
		name : string,
		open : boolean,
		pages : Page[],
		url ?: string,
		enable ?: boolean
	}
	export default {
		data() {
			return {
				list: [{
					id: 'background',
					name: 'background',
					open: false,
					pages: [
						{
							name: 'background-color',
							url: '/pages/CSS/background/background-color'
						},
						{
							name: 'background-image',
							url: '/pages/CSS/background/background-image'
						}
					] as Page[]
				}, {
					id: 'border',
					name: 'border',
					open: false,
					pages: [
						{
							name: 'border',
W
wanganxp 已提交
63
							url: '/pages/CSS/border/border'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
64 65 66
						},
						{
							name: 'border-width',
W
wanganxp 已提交
67
							url: '/pages/CSS/border/border-width'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
68 69 70
						},
						{
							name: 'border-style',
W
wanganxp 已提交
71
							url: '/pages/CSS/border/border-style'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
72 73 74
						},
						{
							name: 'border-color',
W
wanganxp 已提交
75
							url: '/pages/CSS/border/border-color'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
76 77 78
						},
						{
							name: 'border-radius',
W
wanganxp 已提交
79
							url: '/pages/CSS/border/border-radius'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
80 81 82 83 84 85 86 87 88
						}
					] as Page[]
				}, {
					id: 'box-shadow',
					name: 'box-shadow',
					open: false,
					pages: [
						{
							name: 'box-shadow',
W
wanganxp 已提交
89
							url: '/pages/CSS/box-shadow/box-shadow'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
90 91 92 93 94 95 96 97 98
						},
					] as Page[]
				}, {
					id: 'flex',
					name: 'flex',
					open: false,
					pages: [
						{
							name: 'align-content',
W
wanganxp 已提交
99
							url: '/pages/CSS/flex/align-content'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
100 101 102
						},
						{
							name: 'align-items',
W
wanganxp 已提交
103
							url: '/pages/CSS/flex/align-items'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
104 105 106
						},
						{
							name: 'flex-basis',
W
wanganxp 已提交
107
							url: '/pages/CSS/flex/flex-basis'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
108 109 110
						},
						{
							name: 'flex-direction',
W
wanganxp 已提交
111
							url: '/pages/CSS/flex/flex-direction'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
112 113 114
						},
						{
							name: 'flex-flow',
W
wanganxp 已提交
115
							url: '/pages/CSS/flex/flex-flow'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
116 117 118
						},
						{
							name: 'flex-grow',
W
wanganxp 已提交
119
							url: '/pages/CSS/flex/flex-grow'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
120 121 122
						},
						{
							name: 'flex-shrink',
W
wanganxp 已提交
123
							url: '/pages/CSS/flex/flex-shrink'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
124 125 126
						},
						{
							name: 'flex',
W
wanganxp 已提交
127
							url: '/pages/CSS/flex/flex'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
128 129 130
						},
						{
							name: 'justify-content',
W
wanganxp 已提交
131
							url: '/pages/CSS/flex/justify-content'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
132 133 134 135 136 137 138 139 140
						}
					] as Page[]
				}, {
					id: 'layout',
					name: 'layout',
					open: false,
					pages: [
						{
							name: 'height',
W
wanganxp 已提交
141
							url: '/pages/CSS/layout/height'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
142 143 144
						},
						{
							name: 'max-height',
W
wanganxp 已提交
145
							url: '/pages/CSS/layout/max-height'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
146 147 148
						},
						{
							name: 'max-width',
W
wanganxp 已提交
149
							url: '/pages/CSS/layout/max-width'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
150 151 152
						},
						{
							name: 'min-height',
W
wanganxp 已提交
153
							url: '/pages/CSS/layout/min-height'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
154 155 156
						},
						{
							name: 'min-width',
W
wanganxp 已提交
157
							url: '/pages/CSS/layout/min-width'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
158 159 160
						},
						{
							name: 'position',
W
wanganxp 已提交
161
							url: '/pages/CSS/layout/position'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
162 163 164
						},
						{
							name: 'width',
W
wanganxp 已提交
165
							url: '/pages/CSS/layout/width'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
166 167 168 169 170 171 172 173 174
						}
					] as Page[]
				}, {
					id: 'margin',
					name: 'margin',
					open: false,
					pages: [
						{
							name: 'margin-bottom',
W
wanganxp 已提交
175
							url: '/pages/CSS/margin/margin-bottom'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
176 177 178
						},
						{
							name: 'margin-left',
W
wanganxp 已提交
179
							url: '/pages/CSS/margin/margin-left'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
180 181 182
						},
						{
							name: 'margin-right',
W
wanganxp 已提交
183
							url: '/pages/CSS/margin/margin-right'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
184 185 186
						},
						{
							name: 'margin-top',
W
wanganxp 已提交
187
							url: '/pages/CSS/margin/margin-top'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
188 189
						}, {
							name: 'margin',
W
wanganxp 已提交
190
							url: '/pages/CSS/margin/margin'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
191 192 193 194 195 196 197 198 199
						}
					] as Page[]
				}, {
					id: 'padding',
					name: 'padding',
					open: false,
					pages: [
						{
							name: 'padding-bottom',
W
wanganxp 已提交
200
							url: '/pages/CSS/padding/padding-bottom'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
201 202 203
						},
						{
							name: 'padding-left',
W
wanganxp 已提交
204
							url: '/pages/CSS/padding/padding-left'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
205 206 207
						},
						{
							name: 'padding-right',
W
wanganxp 已提交
208
							url: '/pages/CSS/padding/padding-right'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
209 210 211
						},
						{
							name: 'padding-top',
W
wanganxp 已提交
212
							url: '/pages/CSS/padding/padding-top'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
213 214
						}, {
							name: 'padding',
W
wanganxp 已提交
215
							url: '/pages/CSS/padding/padding'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
216 217 218 219 220 221 222 223 224
						}
					] as Page[]
				}, {
					id: 'text',
					name: 'text',
					open: false,
					pages: [
						{
							name: 'color',
W
wanganxp 已提交
225
							url: '/pages/CSS/text/color'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
226 227 228
						},
						{
							name: 'font-family',
W
wanganxp 已提交
229
							url: '/pages/CSS/text/font-family'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
230 231 232
						},
						{
							name: 'font-size',
W
wanganxp 已提交
233
							url: '/pages/CSS/text/font-size'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
234 235 236
						},
						{
							name: 'font-style',
W
wanganxp 已提交
237
							url: '/pages/CSS/text/font-style'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
238 239 240
						},
						{
							name: 'font-weight',
W
wanganxp 已提交
241
							url: '/pages/CSS/text/font-weight'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
242 243 244
						},
						{
							name: 'line-height',
W
wanganxp 已提交
245
							url: '/pages/CSS/text/line-height'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
246 247 248
						},
						{
							name: 'text-align',
W
wanganxp 已提交
249
							url: '/pages/CSS/text/text-align'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
250 251 252
						},
						{
							name: 'text-decoration-line',
W
wanganxp 已提交
253
							url: '/pages/CSS/text/text-decoration-line'
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
254 255
						}
					] as Page[]
256 257 258 259 260 261 262
				}, {
					id: 'animate',
					name: '动画',
					open: false,
					pages: [
						{
							name: 'transition',
W
wanganxp 已提交
263
							url: '/pages/CSS/transition/transition'
264 265 266
						},
						{
							name: 'transform',
W
wanganxp 已提交
267
							url: '/pages/CSS/transform/transform'
268 269
						}
					] as Page[]
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
				}
				] as ListItem[],
				arrowUpIcon: '/static/icons/arrow-up.png',
				arrowDownIcon: '/static/icons/arrow-down.png',
				arrowRightIcon: '/static/icons/arrow-right.png',
			}
		},
		methods: {
			triggerCollapse(index ?: number, item : ListItem) {
				if (item.pages.length == 0) {
					const page : Page = {
						name: item.name,
						enable: item.enable,
						url: item.url
					}
					this.goDetailPage(page);
					return;
				}
				for (var i = 0; i < this.list.length; ++i) {
					if (index == i) {
						this.list[i].open = !this.list[i].open;
					} else {
						this.list[i].open = false;
					}
				}
			},
			goDetailPage(e : Page) {
297
				if (e.enable == false) {
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
					uni.showToast({
						icon: 'none',
						title: '暂不支持'
					})
					return
				}
				const url = e.url != null ? e.url! : `/pages/CSS/${e.name}/${e.name}`
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style>
314
	@import '../../common/uni-uvue.css';
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
315
</style>