uniapp访问外部页面链接(web-view):
通过页面跳转访问到指定页面:
uni.navigateTo({
url: "pages/webview/webview?url=https://www.baidu.com"
});
配置好外部访问页面:
<template>
<view class="container">
<web-view :src="urlView" class="iframe"></web-view>
</view>
</template>
<script>
export default {
name: 'webview',
data() {
return {
urlView: '',
};
},
onLoad(query) {
// 获取url参数
this.urlView = decodeURIComponent(query.url);
console.log("页面路径为?",this.urlView)
},
}
</script>
<style>
.container {
height: 100vh;
padding: 0 30rpx;
box-sizing: border-box;
}
.iframe {
width: 100%;
height: 100%;
}
</style>
注意:
uniapp上需要注意配置好对应的router路径!