fix Button open link when use to and target _blank

This commit is contained in:
梁灏 2021-04-23 11:34:58 +08:00
parent 67beea14d6
commit 9d6b5f0381

View file

@ -42,10 +42,8 @@ export default {
} }
}, },
methods: { methods: {
handleClick (new_window = false) { handleOpenTo () {
const router = this.$router; const router = this.$router;
if (new_window) {
let to = this.to; let to = this.to;
if (router) { if (router) {
const current = this.$route; const current = this.$route;
@ -53,6 +51,12 @@ export default {
to = route ? route.href : this.to; to = route ? route.href : this.to;
} }
window.open(to); window.open(to);
},
handleClick (new_window = false) {
const router = this.$router;
if (new_window) {
this.handleOpenTo();
} else { } else {
if (router) { if (router) {
if ((typeof this.to === 'string') && this.to.includes('//')) { if ((typeof this.to === 'string') && this.to.includes('//')) {
@ -68,6 +72,7 @@ export default {
handleCheckClick (event, new_window = false) { handleCheckClick (event, new_window = false) {
if (this.to) { if (this.to) {
if (this.target === '_blank') { if (this.target === '_blank') {
this.handleOpenTo();
return false; return false;
} else { } else {
event.preventDefault(); event.preventDefault();