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

Cannot destructure property ‘username‘ of ‘undefined‘ as it is undefined

這篇具有很好參考價值的文章主要介紹了Cannot destructure property ‘username‘ of ‘undefined‘ as it is undefined。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

背景

實現(xiàn)注冊功能,控制臺報錯:

Cannot destructure property 'username' of 'undefined' as it is undefined

原因

  • 不知道

  • 導(dǎo)出發(fā)請求的函數(shù)時使用解構(gòu)賦值攜帶了未定義的參數(shù)

// src\api\index.js
export const register = ({ username, password, repassword }) => {
  return request({
    url: '/api/reg',
    method: 'POST',
    data: {
      username: username,
      password: password,
      repassword: repassword
    }
  })
}
// src\views\register\index.vue
    registerFn () {
      this.$refs.form.validate(async valid => {
        if (valid) {
          const res = await register(this.form)
        }
      })
    }

解決

  • 在頁面處處理解構(gòu)文章來源地址http://www.zghlxwxcb.cn/news/detail-768146.html

// src\api\index.js
export const register = (data) => {
  return request({
    url: '/api/reg',
    method: 'POST',
    data
  })
}
// src\views\register\index.vue
    registerFn () {
      const { username, password, repassword } = this.form
      this.$refs.form.validate(async valid => {
        if (valid) {
          const res = await register({ username, password, repassword }) 
? ? ? ? } 
? ? }

到了這里,關(guān)于Cannot destructure property ‘username‘ of ‘undefined‘ as it is undefined的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

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

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

相關(guān)文章

  • Cannot read properties of undefined (reading ‘key‘)

    如標(biāo)題所示錯誤,直譯是key為undefined。本次是因為使用了element-ui中的el-table組件所以并不是key為undefined,而是后臺返回的key有重復(fù)。 當(dāng)key重復(fù)就會出現(xiàn)頁面卡死的現(xiàn)象,渲染就會失敗。 key在使用時我們要注意: 1.在渲染時該識別為不同時,識別為相同 2.在渲染時該識別為相

    2024年02月03日
    瀏覽(18)
  • 【JS】如何解決Cannot set properties of undefined

    TypeError: Cannot set properties of undefined 類型錯誤:無法設(shè)置未定義的屬性 問題解析 當(dāng)前的是當(dāng)前對象或者數(shù)組是undefined,但是卻用來引用屬性或者索引 比如下面兩種情況 或者是當(dāng)前的value值不是我們顯式聲明的undefined,而是運算之后得到undefined,之后我們再去用它 解決方案 問

    2024年02月16日
    瀏覽(18)
  • TypeError: Cannot read property ‘setRules‘ of undefined“

    TypeError: Cannot read property ‘setRules‘ of undefined“

    1.uniapp 執(zhí)行小程序表單校驗時報錯 使用如果使用v-if,則使用v-show替換v-if ,即可解決問題

    2024年02月06日
    瀏覽(23)
  • 解決Cannot read properties of undefined (...)類型的報錯

    解決Cannot read properties of undefined (...)類型的報錯

    場景: 在項目中,想要獲取鼠標(biāo)的元素,紅色區(qū)域報錯:Cannot read properties of undefined (reading \\\'grid3D\\\') 分析: Cannot read properties of undefined類型的報錯,一般是報錯元素的前一個元素出了問題,也就是this.option沒有獲取到。 報錯類型一般為兩種: 對象沒值的時候 對象為undefined的時

    2024年02月12日
    瀏覽(24)
  • 解決Cannot read properties of undefined (reading ‘resetFields‘)

    解決Cannot read properties of undefined (reading ‘resetFields‘)

    第一天做項目中遇到了這一個問題關(guān)于resetField重置校驗報錯的問題, ? 然后去網(wǎng)上查找問題的原因,但是找到問題的原因是: mouted加載table數(shù)據(jù)以后,隱藏的 Dialog 并沒有編譯渲染進 dom 里面。所以當(dāng)通過點擊事件,Dialog 彈出的時候,$refs 并沒有獲取到 dom 元素導(dǎo)致 ‘reset

    2023年04月23日
    瀏覽(23)
  • 解決 Cannot read properties of undefined類型的報錯

    報錯類型一般為兩種 對象類型 對象沒有數(shù)據(jù)的時候為undefined 這個時候訪問內(nèi)部內(nèi)容就會報錯 舉個例子 正常情況 對象有值的時候 var obj={name:‘張三’,age:18} #此時對象有數(shù)據(jù)訪問不會報錯 console.log(obj.name) 1 2 3 對象沒值的時候 var obj={} console.log(obj.name) #就會報錯 Uncaught Syntax

    2023年04月21日
    瀏覽(14)
  • 解決:使用前端路由時的報錯Cannot destructure property ‘options’ of ‘(0 , vue__WEBPACK_IMPORTED_MODULE_1__.inject)

    解決:使用前端路由時的報錯Cannot destructure property ‘options’ of ‘(0 , vue__WEBPACK_IMPORTED_MODULE_1__.inject)

    使用前端路由時,代碼無誤,但是頁面不顯示任何東西,控制臺報錯: Cannot destructure property ‘options’ of ‘(0 , vue__WEBPACK_IMPORTED_MODULE_1__.inject)(…)’ as it is undefined. step1: step3 最終就可以得到期望的效果啦

    2024年02月16日
    瀏覽(19)
  • 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. 解釋:當(dāng)我們使用內(nèi)置 use開頭的鉤子函數(shù)時,不能進行嵌套去拿實例。如: 解決:必須在 setup函數(shù) 第一層調(diào)用。

    2024年02月11日
    瀏覽(21)
  • TypeError: Cannot read properties of undefined (reading ‘map‘)

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

    控制臺報錯 TypeError: Cannot read properties of undefined (reading \\\'map\\\') 我的錯誤原因: 第一次頁面渲染的時候,map的對象是undefined或null, 解決方法: 在前面加個要進行判斷,當(dāng)有值時再去遍歷

    2024年02月07日
    瀏覽(28)
  • [已解決]Cannot read properties of undefined (reading ‘install‘)

    唉,對于計算機的bug是真的很害怕。但是這個錯誤,我發(fā)現(xiàn)解決起來還是蠻簡單的。 參考這篇博客: (2條消息) 錯誤“Cannot read properties of undefined (reading ‘install‘) at Vue.use” 的解決方案_cannot read properties of undefined (reading \\\'inst_FunSober的博客-CSDN博客 原因主要就是我們在下載

    2024年02月13日
    瀏覽(25)

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

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

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

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

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包