template.uvue 768 字节
Newer Older
study夏羽's avatar
study夏羽 已提交
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
<template>
	<view class="container">
		<template v-if="isShow">
			<view>{{title}}</view>
		</template>
		<view class="show-botton" @click="handleShow">{{isShow?'点击隐藏':'点击显示'}}</view>

		<template v-for="(item,index) in list" :key="index">
			<view class="item">{{index+1}}.{{item.name}}</view>
		</template>
	</view>
</template>

<script>
	type objType = {
		name: string
	}
	export default {
		data() {
			return {
				title: "hello",
				isShow: true,
				list: [{
						name: 'foo1'
					},
					{
						name: 'foo2'
					}
				] as objType[]
			}
		},
		methods: {
			handleShow() {
				this.isShow = !this.isShow
			}
		}
	}
</script>

<style>
	.item {
		display: flex;
		flex-direction: row;
		margin: 15px;
		border: #eee solid 1px;
	}
</style>