template-composition.uvue 1.1 KB
Newer Older
1 2
<template>
  <view class="page">
3
    <template v-if="dataInfo.isShow">
DCloud-WZF's avatar
DCloud-WZF 已提交
4
      <text id="title">{{ title }}</text>
5
    </template>
DCloud-WZF's avatar
DCloud-WZF 已提交
6
    <button id="show-botton" @click="handleShow">{{ dataInfo.isShow ? '点击隐藏' : '点击显示' }}</button>
7 8 9 10 11 12 13 14
    <template v-for="(item, index) in list" :key="index">
      <view class="item">{{ index + 1 }}.{{ item.name }}</view>
    </template>
    <button @click="goMapStyle">跳转绑定 Map 类型 style 页面</button>
  </view>
</template>

<script setup lang="uts">
15 16 17
type DataInfo = {
  isShow: boolean
}
18
type ListItem = {
D
DCloud_LXH 已提交
19 20
  name: string
}
21

22 23 24
const dataInfo = reactive({
  isShow: false
} as DataInfo)
25

D
DCloud_LXH 已提交
26
const title = ref<string>('hello')
27 28 29 30 31 32 33
const list = ref<ListItem[]>([
  {
    name: 'foo1'
  },
  {
    name: 'foo2'
  }
DCloud-WZF's avatar
DCloud-WZF 已提交
34
])
35

36 37 38 39
const handleShow = () => {
  dataInfo.isShow = !dataInfo.isShow
}

40
const goMapStyle = () => {
DCloud-WZF's avatar
DCloud-WZF 已提交
41
  uni.navigateTo({ url: '/pages/built-in/special-elements/template/template-map-style-composition' })
D
DCloud_LXH 已提交
42
}
43 44

defineExpose({
45
  dataInfo,
46
  goMapStyle
D
DCloud_LXH 已提交
47
})
48 49 50 51 52 53 54 55 56 57
</script>

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