window.location.href in VUE 3 JS



我在这里没有得到问题。

当我使用时

return window.location.href = 'https://www.google.com';

它运行良好。但是,如果我使用字符串变量。它不起作用。重新加载回页面。

return window.location.href = this.navigationURL;

完整代码:-

<table class="">
<tr
class="cursor-pointer"
v-for="currentView in authenticationMethodsAvailable"
:key="currentView.id"
>
<td class=""> (HERE)
**<button type= "button" @click="authenticationChoice(currentView['name'])" >**
<img
class="w-12 inline-block align-middle"
:src="showAuthenticationIcon(currentView['gitType'])"

/>
</button>
</td>
</tr>
</table>

正在触发的功能


authenticationChoice(recieved) {
this.$store.state.gitSourceAuthenticationChoice = recieved;
this.$store.dispatch("gitSourceAuthenticationURL").then((response) => {
this.navigationURL = response["oauth2_redirect"];
console.log(this.navigationURL)

});
return this.navigationURL ;
// return window.location.href = String(this.navigationURL);
},

删除破坏代码的返回,并将代码移动到then块内,如下所示:

authenticationChoice(recieved) {
this.$store.state.gitSourceAuthenticationChoice = recieved;
this.$store.dispatch("gitSourceAuthenticationURL").then((response) => {
this.navigationURL = response["oauth2_redirect"];
console.log(this.navigationURL)
window.location.href = String(this.navigationURL);
});

},

最新更新