对于组合API,我有与文档watch和vue router中的几乎相同的示例.但是console.log
永远不会被触发,即使route.params.gameId
正确地显示在模板中
<script setup>
import { ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import { useStore } from 'vuex'
const store = useStore()
const route = useRoute()
watch(
() => route.params.gameId,
async newId => {
console.log("watch"+newId)
}
)
</script>
<template>
<div>
{{route.params.gameId}}
</div>
</template>
我做错了什么?我也try 使手表函数非同步,但这并没有改变任何事情,稍后我将需要它来获取API,所以它应该是异步的.