web-view-local.uvue 972 字节
Newer Older
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
1
<template>
H
hdx 已提交
2 3 4
  <web-view ref="web-view" class="web-view" src="/hybrid/html/local.html" @message="message" @error="error"
    @loading="loading" @loaded="loaded">
  </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 16 17
      }
    },
    methods: {
      message(event : WebViewMessageEvent) {
        console.log(JSON.stringify(event.detail));
W
微调  
wanganxp 已提交
18 19 20 21
        uni.showModal({
          content: JSON.stringify(event.detail),
          showCancel: false
        });
22 23
      },
      error(event : WebViewErrorEvent) {
shutao-dc's avatar
shutao-dc 已提交
24
        this.loadError = true
25 26 27 28 29 30
        console.log(JSON.stringify(event.detail));
      },
      loading(event : WebViewLoadingEvent) {
        console.log(JSON.stringify(event.type));
      },
      loaded(event : WebViewLoadedEvent) {
31
        this.loadFinish = true;
32 33 34 35
        console.log(JSON.stringify(event.type));
      }
    }
  }
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
36 37 38
</script>

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