flex.uvue 1021 字节
Newer Older
DCloud-yyl's avatar
DCloud-yyl 已提交
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
<template>
<!-- #ifdef APP -->
<view class="page" style="flex:1">
<!-- #endif -->
	<view class="head">
		<text class="tip">下面有一个灰色区域,display默认值为flex</text>
		<text class="tip">当前display值:{{display}}</text>
	</view>
	<view class="content" :style="{display:display}">
		<text style="background-color: aquamarine;">展示display区域</text>
	</view>
	<button @tap="switchDisplay">切换display属性</button>
<!-- #ifdef APP -->
</view>
<!-- #endif -->
</template>

<script>
export default {
	data() {
		return {
			display: 'flex'
		}
	},
	methods: {
		switchDisplay() {
			this.display = ('flex'==this.display)?'none':'flex';
		}
	}
}
</script>

<style>
.page {
	align-items: center;
	height: 100%;
}
.head {
	margin-top: 10px;
	margin-bottom: 10px;
	align-items: center;
}
.tip {
	color: red;
}
.content {
	border: 10rpx dotted blue;
	margin: 50px 0px;
	padding: 50px;
	width: 200px;
	height: 200px;
	background-color: gray;
	align-items: center;
	justify-content: center;
}
</style>