尝试使用onsort事件时,Lightning数据表会引发错误

问题描述

尝试对闪电数据表进行排序时,会弹出错误“ NoErrorObjectAvailable”。

HTML:

       key-field="Id"
       data={jobItems}
       columns={columns}
       hide-checkbox-column
       onrowaction={handleRowAction}
       onsort={updateColumnSorting}
   ></lightning-datatable>```

JS:
updateColumnSorting(event)
{          
   var fieldName = event.detail.fieldName;
   var sortDirection = event.detail.sortDirection;

   console.log('## fieldName: ' + fieldName);
   console.log('## sortDirection: ' + sortDirection);
            
}```

ERROR:

[NoErrorObjectAvailable]脚本错误。 a()@https://static.lightning.force.com/cs70/auraFW/javascript/7p9HLMpgnV2GO9Mq/aura_prod.js:948:169 {anonymous}()@https://static.lightning.force.com/cs70/auraFW/javascript/7p9HLMpgnV2GO9Mq/aura_prod.js:948:362 ln.dispatchEvent()@https://static.lightning.force.com/cs70/auraFW/javascript/7p9HLMpgnV2GO9Mq/aura_prod.js:12:12146 ln.fireSortedColumnChange()@https://COMPANY_NAME--SANDBOX_NAME.lightning.force.com/components/lightning/datatable.js:2:66247 ln.handleUpdateColumnSort()@https://COMPANY_NAME--SANDBOX_NAME.lightning.force.com/components/lightning/datatable.js:2:65875```

解决方法

今天,当我尝试从lightning-combobox的{​​{1}}处理程序调度自定义事件时遇到了类似的问题。帮助我摆脱错误的是将onchange更改为var

不起作用

const

工作

 handleSearchOptionChange(event) {
      console.log(event.detail,event.detail.value);
      this.selectedBoatTypeId = event.detail.value;

      var searchEvent = new CustomEvent('search',{ detail:{ boatTypeId: event.detail.value }});
      this.dispatchEvent(searchEvent);
 }

不确定在您的特定情况下是否相同,但想共享它,因为这花费了我大约45分钟的调试时间...

,

发现了问题。错误是在VS Code中将排序函数错误地放在另一个函数中。通过适当的突出显示和所有内容,保存起来很好。仅当我尝试在其后立即编写getter函数时,它才会出错。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...