We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.6.5
因为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 }
想要watch能监听到useRoute().query的变化。 在vue-router3中加入useRoute和useRouter钩子函数。
watch能不能监听到替代方案useRoute().query的变化。
The text was updated successfully, but these errors were encountered:
They are already there:
import { useRouter } from 'vue-router/composables'
https://github.com/vuejs/vue-router/blob/dev/src/composables/index.js
Sorry, something went wrong.
excellent! import { useRouter } from 'vue-router/composables' it can be watch and work.
No branches or pull requests
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的变化。
The text was updated successfully, but these errors were encountered: