收藏
回答

web-view 加载同一个url会开启多个页面的bug

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug web-view 微信iOS客户端 7.0.8 2.8.2

您好!现在我们遇到这样一个问题,下面详细说明并附上代码,望您解决,谢谢!

问题描述:不断点击连接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>




回答关注问题邀请回答
收藏
登录 后发表内容
问题标签