Error in v-on handler: “ReferenceError:xxx is not defined

一级标题 [Vue warn]: Error in v-on handler: “ReferenceError: xxx is not defined”

found in.

在网上查了一下,发现大家大部分都是未将xxx传入该组件。

参考:https://blog.csdn.net/qq_41672008/article/details/89203991

或者是因为子传父中 父元素接受数据的时候没有传参数。

参考:https://blog.csdn.net/xiaoerlang715/article/details/94382221

或者是未引用该组件

参考:https://blog.csdn.net/new_Petrichor/article/details/120431079?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_antiscanv2&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_antiscanv2

而本人的均不是上述情况,本人的“xxx”为自己定义的变量,由于在methods中使用该变量时,忘记填加"this."而导致出错,添加上this.即可解决问题

      moreChsCountAddBtn(){
        this.moreChsCount+=1;
        this.moreChs.title.push("moreChs_title_"+moreChsCount)
        this.moreChs.content.push("moreChs_content_"+this.moreChsCount)        
        this.moreChs.moreChsOptions.push("moreChs_options_A_"+this.moreChsCount)
        this.moreChs.moreChsOptions.push("moreChs_options_B_"+this.moreChsCount)
        this.moreChs.moreChsOptions.push("moreChs_options_C_"+this.moreChsCount)
        this.moreChs.moreChsOptions.push("moreChs_options_D_"+this.moreChsCount)  
        this.moreChs.options_answer.push("moreChs_answer_"+this.moreChsCount)
        console.log(this.moreChs.title)
        console.log(this.moreChs.moreChsOptions)
        console.log(this.moreChs.options_answer)
        console.log(this.moreChsCount)
      },

  • 5
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据引用\[1\]中的解释,问题出现在v-on命令中的isCollect变量没有定义。你在代码中已经在data中定义了isCollect变量,但是在方法中使用实例上的变量时,必须使用this来指向这个变量。所以,你需要在v-on命令中使用this.isCollect来引用isCollect变量,这样问题就可以解决了。 #### 引用[.reference_title] - *1* [Error in v-on handler: “ReferenceError: isShow is not defined](https://blog.csdn.net/m0_50013284/article/details/125717671)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Error in v-on handler: “ReferenceError: state is not defined](https://blog.csdn.net/linduj/article/details/127211351)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Vue.js报错问题解决:[Vue warn]: Error in v-on handler: “ReferenceError: XXX is not defined“.](https://blog.csdn.net/m0_56426418/article/details/130162657)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值