webview-screenshot.uvue 841 字节
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
<template>
  <web-view id="webview-screenshot" class="webview-screenshot" :webview-styles='webviewStyles' :src="src"
    @loaded="loaded" @error="error">
  </web-view>
</template>

<script>
  export default {
    data() {
      return {
        baseSrc: '',
        src: '',
        webviewContext: null as WebviewContext | null,
        isLoaded: false,
        webviewStyles: {
          progress: false
        }
      }
    },
    onReady() {
      this.webviewContext = uni.createWebviewContext('webview-screenshot', this)
    },
    methods: {
      loaded() {
        this.isLoaded = true
      },
      error(event : WebViewErrorEvent) {
        console.log('webview load error', JSON.stringify(event.detail));
      }
    }
  }
</script>
<style>
  .webview-screenshot {
    flex: 1;
  }
</style>