TypeError: Cannot set properties of undefined

TypeError: Cannot set properties of undefined ,第1张

使用ANT DESIGN VUE组件库中的table时,使用文档中的行点击方法,获取到点击行的信息,并且赋值给其他字段报错TypeError: Cannot set properties of undefined (setting 'name')


               
              

data(){
    return{
        data:[],
        columns:[],
        name:'' //需要赋值的已经定义
}}
methods:{
customRow(record, index) {
     
      return {
        on: {
          click() {
            console.log(record)  //打印成功
            this.name = record.name  //赋值报错
           
          }
        }
      }
}
}
 解决办法:var that=this
customRow(record, index) {
      var that = this
      return {
        on: {
          click() {
            console.log(record)
            that.time = record.time
          }
        }
      }
    },

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/945654.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-18
下一篇2022-05-18

发表评论

登录后才能评论

评论列表(0条)

    保存