object.uvue 1.1 KB
Newer Older
shutao-dc's avatar
shutao-dc 已提交
1
<template>
2 3 4
  <view>
    <!-- #ifdef APP-ANDROID -->
    <native-button class="native-button" style="width: 200px; height: 100px;" :text="buttonText" @buttonTap="ontap"
5
      @load="onload"></native-button>
6 7
    <time-picker class="native-time-picker" :hour=2 :minute=3 @changed="onChanged"></time-picker>
    <!-- #endif -->
shutao-dc's avatar
shutao-dc 已提交
8
  </view>
shutao-dc's avatar
shutao-dc 已提交
9 10 11
</template>

<script>
shutao-dc's avatar
shutao-dc 已提交
12 13 14 15 16 17 18 19 20
  export default {
    data() {
      return {
        title: 'Hello',
        buttonText: "封装object实现的button",
        isLoad: false
      }
    },
    onLoad() {
shutao-dc's avatar
shutao-dc 已提交
21

shutao-dc's avatar
shutao-dc 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
    },
    methods: {
      ontap(e : UniObjectCustomEvent) {
        uni.showToast({
          title: "按钮被点击了"
        })
      },
      onload() {
        //标记已初始化 用于自动化测试
        this.isLoad = true
      },
      onChanged(e : UniObjectCustomEvent) {
        console.log("onchanged-----", e.detail)
      }
    }
  }
shutao-dc's avatar
shutao-dc 已提交
38 39 40
</script>

<style>
shutao-dc's avatar
shutao-dc 已提交
41 42 43 44 45
  .native-button {
    height: 100px;
    width: 100px;
    margin: 25px auto 25px auto;
  }
shutao-dc's avatar
shutao-dc 已提交
46

shutao-dc's avatar
shutao-dc 已提交
47 48 49
  .native-time-picker {
    margin: 10px auto 25px auto;
  }
shutao-dc's avatar
shutao-dc 已提交
50
</style>