<template>
<div class="about">
<h1>This is an about page</h1>
<h3>{{msg}}</h3>
<button ref="btn" @click="clickHandler">button</button>
</div>
</template>
<script>
export default {
props: {
msg: {
required: true,
type: String
}
},
data () {
return {
url: 'http://www.baidu.com/',
newTab: null
}
},
mounted () {},
methods: {
clickHandler () {
this.newTab = window.open('about:blank')
let $ajax = new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, 1000)
})
$ajax.then(() => {
this.newTab.location.href = this.url
setTimeout(() => {
this.newTab = null
}, 1)
})
}
}
}
</script>