web-view-local.uvue 952 字节
Newer Older
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
1
<template>
H
hdx 已提交
2
  <web-view ref="web-view" class="web-view" src="/hybrid/html/local.html" @message="message" @error="error"
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
3
    @loading="loading" @load="load">
H
hdx 已提交
4
  </web-view>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
5 6 7
</template>

<script>
8 9 10
  export default {
    data() {
      return {
11 12
        loadError: false,
        loadFinish: false
13 14 15
      }
    },
    methods: {
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
16 17
      message(event : UniWebViewMessageEvent) {
        console.log(JSON.stringify(event));
W
微调  
wanganxp 已提交
18 19 20 21
        uni.showModal({
          content: JSON.stringify(event.detail),
          showCancel: false
        });
22
      },
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
23
      error(event : UniWebViewErrorEvent) {
shutao-dc's avatar
shutao-dc 已提交
24
        this.loadError = true
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
25
        console.log(JSON.stringify(event));
26
      },
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
27 28
      loading(event : UniWebViewLoadingEvent) {
        console.log(JSON.stringify(event));
29
      },
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
30
      load(event : UniWebViewLoadEvent) {
31
        this.loadFinish = true;
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
32
        console.log(JSON.stringify(event));
33 34 35
      }
    }
  }
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
36 37 38
</script>

<style>
H
hdx 已提交
39 40 41
.web-view {
  flex: 1;
}
W
微调  
wanganxp 已提交
42
</style>