-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Closed
Description
Version
3.6.5
Steps to reproduce
因为vue2.7是支持组合式API的,但是又只支持vue-router3,vue-router3 又没有实现useRoute和useRouter钩子函数。这就导致我们自己实现的钩子函数useRoute和useRouter无法在watch中被监听到变化,主要是useRoute().query的变化。
我们自己封装的钩子如下:
import { getCurrentInstance } from 'vue'
/** this.$route替换方案 /
export function useRoute() {
const { proxy } = getCurrentInstance()
const route = proxy.$route
return route
}
/* this.$router替换方案 */
export function useRouter() {
const { proxy } = getCurrentInstance()
const router = proxy.$router
return router
}
What is expected?
想要watch能监听到useRoute().query的变化。
在vue-router3中加入useRoute和useRouter钩子函数。
What is actually happening?
watch能不能监听到替代方案useRoute().query的变化。
Metadata
Metadata
Assignees
Labels
No labels