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,17 +42,21 @@ export default {
} }
}, },
methods: { methods: {
handleOpenTo () {
const router = this.$router;
let to = this.to;
if (router) {
const current = this.$route;
const route = router.resolve(this.to, current, this.append);
to = route ? route.href : this.to;
}
window.open(to);
},
handleClick (new_window = false) { handleClick (new_window = false) {
const router = this.$router; const router = this.$router;
if (new_window) { if (new_window) {
let to = this.to; this.handleOpenTo();
if (router) {
const current = this.$route;
const route = router.resolve(this.to, current, this.append);
to = route ? route.href : this.to;
}
window.open(to);
} 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();