![cover](https://img-blog.csdnimg.cn/4e86f9007f48447e9833a16b21033ec7.png)
TypeError: Cannot read properties of undefined (reading ‘replace‘)
错误二:[Vue warn]: inject() can only be used inside setup() or functional conponents.错误一:TypeError: Cannot read properties of undefined (reading 'replace')解释:当我们使用内置 use开头的钩子函数时,不能进行嵌套去拿实例。解决:必须在 setup函数
·
错误一:TypeError: Cannot read properties of undefined (reading 'replace')
错误二:[Vue warn]: inject() can only be used inside setup() or functional conponents.
解释:当我们使用内置 use开头的钩子函数时,不能进行嵌套去拿实例。如:
const loginOut = async () => {
// 嵌套在函数内,会提示警告信息
const router = useRouter()
router.replace('/login')
}
解决:必须在 setup函数 第一层调用。
更多推荐
所有评论(0)