使用 window.location.href = "setpass.vue?tel=" + phone 跳轉時,參數明文顯示在地址欄,希望隱藏。
GET 請求參數必然出現在 URL 中,**無法隱藏**。需改用 **POST** 請求,參數放在請求體中。
setPass: function() {
var form = document.createElement('form');
form.style.display = 'none';
form.action = 'setpass.vue';
form.method = 'POST';
form.innerHTML = '';
document.body.appendChild(form);
form.submit();
}
<form method="POST">,字段用 <input type="hidden">。request.form.get('tel'),Spring @RequestParam 默認支持 POST)。