schema.uvue 1001 字节
Newer Older
W
wanganxp 已提交
1
<template>
H
hdx 已提交
2 3 4 5 6 7
  <view>
    <button class="button" @click="openSchema('https://uniapp.dcloud.io/uni-app-x')">使用外部浏览器打开指定URL</button>
    <button class="button" @click="openSchema('market://details?id=com.tencent.mm')">使用应用商店打开指定App</button>
    <button class="button"
      @click="openSchema('androidamap://viewMap?sourceApplication=Hello%20uni-app&poiname=DCloud&lat=39.9631018208&lon=116.3406135236&dev=0')">打开地图坐标</button>
  </view>
W
wanganxp 已提交
8 9 10
</template>

<script>
H
hdx 已提交
11 12
  import Intent from 'android.content.Intent';
  import Uri from 'android.net.Uri';
W
wanganxp 已提交
13

H
hdx 已提交
14 15 16
  export default {
    data() {
      return {
W
wanganxp 已提交
17

H
hdx 已提交
18 19 20 21 22 23 24 25 26 27 28 29
      }
    },
    methods: {
      openSchema(url : string) {
        const context = UTSAndroid.getUniActivity()!;
        const uri = Uri.parse(url)
        const intent = new Intent(Intent.ACTION_VIEW, uri)
        intent.setData(uri);
        context.startActivity(intent);
      }
    }
  }
W
wanganxp 已提交
30 31 32
</script>

<style>
H
hdx 已提交
33 34 35
  .button {
    margin: 15px;
  }
W
wanganxp 已提交
36
</style>