如何解决尝试使用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函数时,它才会出错。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。