您好!现在我们遇到这样一个问题,下面详细说明并附上代码,望您解决,谢谢!
问题描述:不断点击连接1和连接2时 发现web-view会开启多个页面,可是url明明是同一个url,只是Act不一样而以,并且也没有在a标签中加target="_blank" ,我们并不希望出现这样不断开启新页面的结果,希望大神帮解决,谢谢!
wxml代码
<web-view src="{{webview_url}}"></web-view>
小程序js代码
// pages/test/page1.js
var app = getApp();
Page({
data: {
webview_url: ""
},
onLoad: function (options) {
var page = this;
var url=app.globalData.hostUrl + "/tmp.html";
page.setData({
webview_url: url
});
},
onReady: function () {
},
onShow: function () {
},
onHide: function () {
},
onUnload: function () {
},
onPullDownRefresh: function () {
},
onReachBottom: function () {
},
onShareAppMessage: function () {
}
})
html代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta charset="UTF-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta id="viewport" name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="format-detection" content="telephone=no" />
<title>测试页面</title>
<script src="js/jquery/jquery-3.3.1.min.js"></script>
<link href="css/phone_common.css" rel="stylesheet" />
<script type="text/javascript">
$(function () {
var date = new Date();
$("#time").html(date);
});
</script>
</head>
<body>
<div style="padding:1rem;background:#f2f2f2;margin-bottom:2px;"><a href="tmp.html?act=1">连接1</a></div>
<div style="padding:1rem;background:#f2f2f2;margin-bottom:2px;"><a href="tmp.html?act=2">连接2</a></div>
<div id="time"></div>
</body>
</html>