Vue tips
- Vue的生命周期中,
$rounter可能在created和mounted阶段并没有初始化好,这时使用push或者replace是无效的,这时我们可以使用这个方法来解决这个问题:
this.queryParams = this.$route.query
this.$router.onReady(() => {
this.$router.push({ query })
})
$rounter 可能在 created 和 mounted 阶段并没有初始化好,这时使用 push 或者 replace 是无效的,这时我们可以使用这个方法来解决这个问题:this.queryParams = this.$route.query
this.$router.onReady(() => {
this.$router.push({ query })
})