CSS.uvue 8.9 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1
<template>
M
mehaotian 已提交
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
	<!-- #ifdef APP -->
	<scroll-view style="flex: 1">
		<!-- #endif -->
		<view class="uni-container">
			<view class="uni-header-logo">
				<image class="uni-header-image" src="/static/cssIndex.png"></image>
			</view>
			<view class="uni-hello-text">
				<text class="hello-text">uni-app x目前已支持的CSS属性,展示样式仅供参考,文档详见:</text>
				<u-link :href="'https://uniapp.dcloud.io/component/'" :text="'https://uniapp.dcloud.io/component/'" :inWhiteList="true"></u-link>
			</view>
			<uni-collapse>
				<template v-for="item in list" :key="item.id">
					<uni-collapse-item :title="item.name" class="item">
						<view class="uni-navigate-item":hover-class="page.enable == false?'':'is--active'" v-for="(page, key) in item.pages" :key="key" @click="goDetailPage(page)">
							<text class="uni-navigate-text" :class="page.enable == false ? 'text-disabled' : ''">{{ page.name }}</text>
							<image :src="arrowRightIcon" class="uni-icon"></image>
						</view>
					</uni-collapse-item>
				</template>
			</uni-collapse>
			<!-- <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>
					<image :src="
DCloud-WZF's avatar
DCloud-WZF 已提交
27 28 29 30 31
              item.pages.length > 0
                ? item.open
                  ? arrowUpIcon
                  : arrowDownIcon
                : arrowRightIcon
M
mehaotian 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44
            " class="uni-icon"></image>
				</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)">
						<text class="uni-navigate-text" :class="page.enable == false ? 'text-disabled' : ''">{{ page.name }}</text>
						<image :src="arrowRightIcon" class="uni-icon"></image>
					</view>
				</view>
			</view> -->
		</view>
		<!-- #ifdef APP -->
	</scroll-view>
	<!-- #endif -->
DCloud-WZF's avatar
DCloud-WZF 已提交
45 46 47
</template>

<script lang="ts">
M
mehaotian 已提交
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 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 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
	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',
								url: '/pages/CSS/border/border',
							},
							{
								name: 'border-width',
								url: '/pages/CSS/border/border-width',
							},
							{
								name: 'border-style',
								url: '/pages/CSS/border/border-style',
							},
							{
								name: 'border-color',
								url: '/pages/CSS/border/border-color',
							},
							{
								name: 'border-radius',
								url: '/pages/CSS/border/border-radius',
							},
							{
								name: 'border属性复合示例',
								url: '/pages/CSS/border/complex-border/complex-border',
							},
						] as Page[],
					},
					{
						id: 'box-shadow',
						name: 'box-shadow',
						open: false,
						pages: [
							{
								name: 'box-shadow',
								url: '/pages/CSS/box-shadow/box-shadow',
							},
						] as Page[],
					},
					{
						id: 'flex',
						name: 'flex',
						open: false,
						pages: [
							{
								name: 'align-content',
								url: '/pages/CSS/flex/align-content',
							},
							{
								name: 'align-items',
								url: '/pages/CSS/flex/align-items',
							},
							{
								name: 'flex-basis',
								url: '/pages/CSS/flex/flex-basis',
							},
							{
								name: 'flex-direction',
								url: '/pages/CSS/flex/flex-direction',
							},
							{
								name: 'flex-flow',
								url: '/pages/CSS/flex/flex-flow',
							},
							{
								name: 'flex-grow',
								url: '/pages/CSS/flex/flex-grow',
							},
							{
								name: 'flex-shrink',
								url: '/pages/CSS/flex/flex-shrink',
							},
							{
								name: 'flex',
								url: '/pages/CSS/flex/flex',
							},
							{
								name: 'justify-content',
								url: '/pages/CSS/flex/justify-content',
							},
						] as Page[],
					},
					{
						id: 'layout',
						name: 'layout',
						open: false,
						pages: [
							{
								name: 'height',
								url: '/pages/CSS/layout/height',
							},
							{
								name: 'max-height',
								url: '/pages/CSS/layout/max-height',
							},
							{
								name: 'max-width',
								url: '/pages/CSS/layout/max-width',
							},
							{
								name: 'min-height',
								url: '/pages/CSS/layout/min-height',
							},
							{
								name: 'min-width',
								url: '/pages/CSS/layout/min-width',
							},
							{
								name: 'position',
								url: '/pages/CSS/layout/position',
							},
							{
								name: 'width',
								url: '/pages/CSS/layout/width',
							},
							{
								name: 'visibility',
								url: '/pages/CSS/layout/visibility',
							},
						] as Page[],
					},
					{
						id: 'margin',
						name: 'margin',
						open: false,
						pages: [
							{
								name: 'margin-bottom',
								url: '/pages/CSS/margin/margin-bottom',
							},
							{
								name: 'margin-left',
								url: '/pages/CSS/margin/margin-left',
							},
							{
								name: 'margin-right',
								url: '/pages/CSS/margin/margin-right',
							},
							{
								name: 'margin-top',
								url: '/pages/CSS/margin/margin-top',
							},
							{
								name: 'margin',
								url: '/pages/CSS/margin/margin',
							},
						] as Page[],
					},
					{
						id: 'padding',
						name: 'padding',
						open: false,
						pages: [
							{
								name: 'padding-bottom',
								url: '/pages/CSS/padding/padding-bottom',
							},
							{
								name: 'padding-left',
								url: '/pages/CSS/padding/padding-left',
							},
							{
								name: 'padding-right',
								url: '/pages/CSS/padding/padding-right',
							},
							{
								name: 'padding-top',
								url: '/pages/CSS/padding/padding-top',
							},
							{
								name: 'padding',
								url: '/pages/CSS/padding/padding',
							},
						] as Page[],
					},
					{
						id: 'text',
						name: 'text',
						open: false,
						pages: [
							{
								name: 'color',
								url: '/pages/CSS/text/color',
							},
							{
								name: 'font-family',
								url: '/pages/CSS/text/font-family',
							},
							{
								name: 'font-size',
								url: '/pages/CSS/text/font-size',
							},
							{
								name: 'font-style',
								url: '/pages/CSS/text/font-style',
							},
							{
								name: 'font-weight',
								url: '/pages/CSS/text/font-weight',
							},
							{
								name: 'line-height',
								url: '/pages/CSS/text/line-height',
							},
							{
								name: 'text-align',
								url: '/pages/CSS/text/text-align',
							},
							{
								name: 'text-overflow',
								url: '/pages/CSS/text/text-overflow',
							},
							{
								name: 'text-decoration-line',
								url: '/pages/CSS/text/text-decoration-line',
							},
						] as Page[],
					},
					{
						id: 'animate',
						name: '动画',
						open: false,
						pages: [
							{
								name: 'transition',
								url: '/pages/CSS/transition/transition',
							},
							{
								name: 'transform',
								url: '/pages/CSS/transform/transform',
							},
						] as Page[],
					},
				] 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) {
				if (e.enable == false) {
					uni.showToast({
						icon: 'none',
						title: '暂不支持',
					})
					return
				}
				const url = e.url != null ? e.url! : `/pages/CSS/${e.name}/${e.name}`
				uni.navigateTo({
					url,
				})
			},
		},
	}
DCloud-WZF's avatar
DCloud-WZF 已提交
356 357 358
</script>

<style>
M
mehaotian 已提交
359 360 361 362 363
	@import '../../common/uni-uvue.css';
	.item {
		margin-bottom: 12px;
	}
</style>