H5实现预览
<template><iframe :src="_url" style="width:100vw; height: 100vh;" frameborder="0"></iframe>
</template>
<script lang="ts">
export default {data() {return {_url: '',}},onLoad(options: {_url: string}) {// 第一:https://docs.google.com/viewer?url=// 第二:https://view.officeapps.live.com/op/view.aspx?src=this._url = `https://view.officeapps.live.com/op/view.aspx?src=${options._url}`console.log(this._url,'this._url')}
}
</script>
小程序和app预览
uni.downloadFile({url: url,success: function (res) {var filePath = res.tempFilePath;uni.openDocument({filePath: filePath,showMenu: true,success: function (res) {console.log('打开文档成功');}});}});