is_thinking 2015-07-28 08:27 采纳率: 66.7%
浏览 12928
已采纳

请问JavaScript如何隐藏页面跳转时地址栏的参数

页面里不是form表单
button按钮的函数如下:

 setPass: function() {
        window.location.href="setpass.vue?tel=" + this.user.phone;
    }

每次点击按钮时跳转页面地址栏都有参数信息,请问用window.location.href
如何隐藏参数?谢谢

  • 写回答

5条回答 默认 最新

  • 斯洛文尼亚旅游 2015-07-28 08:53
    关注

    get的话肯定是没办法隐藏参数,自己动态创建一个表单,表单method改为post,提交这个表单才行

         setPass: function() {
            var f=document.createElement('form');
            f.style.display='none';
            f.action='setpass.vue';
            f.method='post';
            f.innerHTML='<input type="hidden" name="tel" value="'+this.user.phone+'"/>';
            document.body.appendChild(f);
            f.submit();
            //window.location.href="?tel=" + this.user.phone;
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?