错误一: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函数 第一层调用。

好文推荐

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: