webpack+vue-router+vue-cli的dev模式下,为啥window.location无效
以下Authorize.vu文件在authorize.html中有调用,程序希望在onLogin事件后,跳到loan_apply_info.html页面。但好像不管用啊。
点击authorize.html中的登录按钮时,会调用以下代码中events下的’onLogin‘事件,日志也有打出来,确认是调用到了。浏览器也有reload动作(进度条动了一下),但始终还是在本页。
如果在window.location = ... 前后加上console.log(window.location)输出日志,可以看到window.location没有变化,都是/authorize.html。
以下代码试了window.location和window.open两种方式都无效。
有问题的代码片断在下面:
Authorize.vue
export default {
data () {
return {
LoanAuthPanelSetting: {
title: '请登录',
subtitle: '',
intro: '',
phone_no_label: '',
phone_no_placeholder: '手机号',
auth_code_label: '',
auth_code_placeholder: '验证码',
get_auth_code_btn_label: '获取验证码',
login_btn_label: '登录',
warn_label: '注意事项',
warn_text: '注意事项内容'
},
phone_no: ''
}
},
events: {
// 登录页:获取验证码
'onGetVerifyCode': function (phone_no) {
console.log('[Authorize]:events:onGetVerifyCode():' + phone_no)
// TODO: ajax-call...
},
// 登录页:登录
'onLogin': function (auth_info) {
console.log('[Authorize]:events:onLogin():' + auth_info)
console.log(window.location)
// window.location = '/loan_apply_info.html' ---- 【无效】
window.open('/loan_apply_info.html', '_self') ---- 【改成这句也无效】
}
},
components: {
LoanLoginPanel
}
}
你是怎么解决的呀