template-options.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
    <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>

14 15 16 17
<script lang='uts'>
type DataInfo = {
  isShow: boolean
}
18 19 20 21 22 23 24
type objType = {
  name : string
}
export default {
  data() {
    return {
      title: "hello",
25 26 27
      dataInfo: {
        isShow: false,
      } as DataInfo,
28 29 30 31 32 33 34 35 36 37 38
      list: [{
        name: 'foo1'
      },
      {
        name: 'foo2'
      }
      ] as objType[]
    }
  },
  methods: {
    handleShow() {
39
      this.dataInfo.isShow = !this.dataInfo.isShow
40 41
    },
    goMapStyle() {
DCloud-WZF's avatar
DCloud-WZF 已提交
42
      uni.navigateTo({ url: '/pages/built-in/special-elements/template/template-map-style-options' })
43 44 45 46 47 48 49 50 51 52 53 54 55
    }
  }
}
</script>

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