web-view加载网络html页面的实现及问题
2020-01-06 本文已影响0人
瑟闻风倾
1. web-view加载网络html页面
<template>
<view>
<web-view :src="url" @message="getMessage"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
url: 'https://uniapp.dcloud.io/static/web-view.html'
}
},
onLoad(options) {
if (options && options.url) {
this.url = options.url;
}
},
methods: {
getMessage(event) {
uni.showModal({
content: JSON.stringify(event.detail),
showCancel: false
});
}
}
}
</script>
<style>
</style>
2. 报错问题 -(X-Frame-Options 响应头)
- Google浏览器调试时报错:Refused to display 'URL' in a frame because it set 'X-Frame-Options' to 'DENY'
报错.png
页面展示.png
备注
:手机端调试可正常加载网络页面。 - 分析与解决