TypeError: Cannot read properties of undefined (reading ‘replace‘)

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

猜你喜欢

转载自blog.csdn.net/m0_73461567/article/details/129192210
今日推荐