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

<script>
  export default {
    data() {
      return {
        title: 'Hello',
        buttonText: "native-button",
shutao-dc's avatar
shutao-dc 已提交
15 16
        isLoad: false,
        clickCount: 0
DCloud-WZF's avatar
DCloud-WZF 已提交
17 18 19 20 21 22 23 24 25 26
      }
    },
    onLoad() {

    },
    methods: {
      ontap(e : UniNativeViewEvent) {
        uni.showToast({
          title: "按钮被点击了"
        })
shutao-dc's avatar
shutao-dc 已提交
27 28
        this.clickCount ++
        this.buttonText = "native-button"+this.clickCount
DCloud-WZF's avatar
DCloud-WZF 已提交
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
      },
      onload() {
        //标记已初始化 用于自动化测试
        this.isLoad = true
      },
      onChanged(e : UniNativeViewEvent) {
        console.log("onchanged-----", e.detail)
      }
    }
  }
</script>

<style>
  .native-button {
    height: 100px;
    width: 100px;
    margin: 25px auto 25px auto;
  }

  .native-time-picker {
    margin: 10px auto 25px auto;
shutao-dc's avatar
shutao-dc 已提交
50 51
    border-style: solid;
    border-radius: 5px;
DCloud-WZF's avatar
DCloud-WZF 已提交
52
  }
shutao-dc's avatar
shutao-dc 已提交
53
</style>