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

你可能感兴趣的:(ERROR,npm,node.js,vue.js,前端,javascript)