template-composition.uvue 1.1 KB
Newer Older
1 2
<template>
  <view class="page">
3
    <template v-if="dataInfo.isShow">
4 5
      <view class="title">{{ title }}</view>
    </template>
6
    <view class="show-botton" @click="handleShow">{{ dataInfo.isShow ? '点击隐藏' : '点击显示' }}</view>
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'
  }
D
DCloud_LXH 已提交
34
] as ListItem[])
35

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

40
const goMapStyle = () => {
D
DCloud_LXH 已提交
41 42
  uni.navigateTo({ url: '/pages/built-in/component/template/template-map-style-composition' })
}
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>