国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

使用vue-router出現(xiàn)Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘push‘)

這篇具有很好參考價值的文章主要介紹了使用vue-router出現(xiàn)Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘push‘)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

1.首先展示一下控制臺的報錯信息:

uncaught typeerror: cannot read properties of undefined (reading 'push'),vue,vue.js,javascript,前端文章來源地址http://www.zghlxwxcb.cn/news/detail-760543.html

?2.項目中代碼

const logout = async () => {
  const store = useUserStore()
  const router = useRouter()
  console.log(router) //通過log打印出來的router是undefined
  // 彈出框提示
  await showConfirmDialog({
    title: '溫馨提示',
    message: '您確定要退出當前賬號嗎?'
  })
  store.delUserInfo()
  router.push('/login')
}

總結(jié):出現(xiàn)錯誤的原因是:const router = useRouter()寫在了函數(shù)里面,正確代碼:

const store = useUserStore()
const router = useRouter()
const logout = async () => {
  // 彈出框提示
  await showConfirmDialog({
    title: '溫馨提示',
    message: '您確定要退出當前賬號嗎?'
  })
  store.delUserInfo()
  router.push('/login')
}

到了這里,關(guān)于使用vue-router出現(xiàn)Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘push‘)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • vue Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘comcode‘)

    vue Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘comcode‘)

    ?在查看信息時,界面沒反應(yīng),然后查看控制臺報錯 然后查找獲取數(shù)據(jù)的方法 ?f12查看返回數(shù)據(jù)信息如下: {msg: \\\"操作成功\\\", code: 200} 因為沒有正確返回數(shù)據(jù),導(dǎo)致獲取response.data時是一個undefined ,因此展示數(shù)據(jù)的時候就會出錯 所以修改獲取數(shù)據(jù)的function,然后將獲取的數(shù)據(jù)判

    2024年02月14日
    瀏覽(91)
  • Uncaught Error: [vue-router] “path“ is required in a route configuration 的解決方案

    Uncaught Error: [vue-router] “path“ is required in a route configuration 的解決方案

    其一、報錯的代碼信息為: Uncaught Error: [vue-router] “path“ is required in a route configuration 中文翻譯: 未捕獲的錯誤:[vue-router]“路徑”在路由配置中是必需的 其二、報錯的頁面顯示為: 看到提示,肯定是 vue-router 的 path 的原因報錯; 其一、就是配置路由的時候 多加了一個花

    2024年02月10日
    瀏覽(95)
  • Uncaught (in promise)和Uncaught (in promise) TypeError: Cannot read properties of undefined (readin

    Uncaught (in promise)和Uncaught (in promise) TypeError: Cannot read properties of undefined (readin

    只要在后面加上.catch((e) = {}),就不會報錯了, ? ?這個問題的解決要想resolve(),在commit()不然就會報錯,注意:先后的順序

    2024年02月09日
    瀏覽(46)
  • 解決 Uncaught (in promise) TypeError: list is not iterable 報錯

    解決 Uncaught (in promise) TypeError: list is not iterable 報錯

    最近在項目中遇到 Uncaught (in promise) TypeError: list is not iterable 報錯,雖然不影響代碼運行,但是看著報錯感覺有點難受,試試能不能解決它 看了很多篇文章,都是說使用 Object.keys() 可以解決問題 就先使用 Object.keys() 看看,代碼運行之后 因為 Object.keys() 傳入的是 null 和 undefin

    2024年02月11日
    瀏覽(21)
  • Uncaught (in promise) TypeError: Cannot read properties of null (reading ‘brands)

    Uncaught (in promise) TypeError: Cannot read properties of null (reading ‘brands)

    在寫vue項目時我們經(jīng)常會遇見這種報錯, 報錯: Uncaught (in promise) TypeError: Cannot read properties of null (reading \\\'brands\\\') 這句話意思是:無法讀取null屬性(讀取\\\'brands\\\') ?解決辦法是在需要渲染的地方加一個v-if來判斷數(shù)據(jù)存在 如下圖 搞定?。?

    2024年02月11日
    瀏覽(31)
  • 報`Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource.`錯誤解決辦法

    報`Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource.`錯誤解決辦法

    使用了promise,但是在使用的過程中報Uncaught (in promise)錯誤,第一次遇到這種錯誤,所以在此記錄下,方便以后解決問題 Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource. 錯誤通常出現(xiàn)在使用fetch API發(fā)起網(wǎng)絡(luò)請求時,無法成功獲取資源時拋出的異常。為了解決這個問

    2024年02月11日
    瀏覽(38)
  • JS報錯Uncaught (in promise) TypeError: (intermediate value).format is not a function

    出現(xiàn)“date.format is not a function”錯誤是因為格式方法未在 JavaScript 中實現(xiàn)。 意思是說Format不是一個方法。去查了一下,發(fā)現(xiàn)是javascript已經(jīng)去掉此方法了,要使用的話,需要添加第三方庫。 要解決該錯誤,需要使用第三方包來格式化我們的日期,例如 moment 或 date-fns。 再或者

    2024年02月17日
    瀏覽(96)
  • setup語法糖報錯 vue-router.mjs:3451 TypeError: Failed to fetch dynamically imported module:

    當直接將setup寫在script標簽上 會報錯 vue-router.mjs:3451 TypeError: Failed to fetch dynamically imported module: 這是setup語法糖導(dǎo)致的錯誤,此時就老老實實按照vue3原本的寫法export default{xxxxxx}即可解決 vue3中setup語法糖寫法: 原始正常寫法: 改成原始寫法后就不報錯了?。?!看來還是不能偷

    2024年02月12日
    瀏覽(20)
  • Uncaught SyntaxError: The requested module ‘/node_modules/.vite/deps/vue-router.js?v=9eef87ba‘

    錯誤代碼 錯誤提示 瀏覽器中路由無法顯示,提示錯誤 問題描述 解決方法

    2024年02月05日
    瀏覽(107)
  • vite+ts出現(xiàn)紅色波浪線;找不到模塊“vue-router

    提示:找不到模塊“vue-router”。你的意思是要將 \\\"moduleResolution\\\" 選項設(shè)置為 \\\"node\\\",還是要將別名添加到 \\\"paths\\\" 選項中?ts(2792) 解決方案一: 查看官方文檔:https://www.tslang.cn/docs/handbook/migrating-from-javascript.html 獲取聲明文件 如果你開始做轉(zhuǎn)換到TypeScript導(dǎo)入,你可能會遇到 Canno

    2024年02月08日
    瀏覽(21)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包