web-view-local.uvue 1000 字节
Newer Older
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
1
<template>
2 3 4 5 6
  <view class="uni-flex-item">
    <web-view ref="web-view" class="uni-flex-item" src="/hybrid/html/local.html" @message="message" @error="error"
      @loading="loading" @loaded="loaded">
    </web-view>
  </view>
DCloud-yinjiacheng's avatar
DCloud-yinjiacheng 已提交
7 8 9
</template>

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

<style>

W
微调  
wanganxp 已提交
42
</style>