錯誤一:TypeError: Cannot read properties of undefined (reading 'replace')
錯誤二:[Vue warn]: inject() can only be used inside setup() or functional conponents.
解釋:當我們使用內置 use開頭的鉤子函數(shù)時,不能進行嵌套去拿實例。如:文章來源:http://www.zghlxwxcb.cn/news/detail-506219.html
const loginOut = async () => {
? // 嵌套在函數(shù)內,會提示警告信息
const router = useRouter()
router.replace('/login')
}
解決:必須在 setup函數(shù) 第一層調用。文章來源地址http://www.zghlxwxcb.cn/news/detail-506219.html
到了這里,關于TypeError: Cannot read properties of undefined (reading ‘replace‘)的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!