- 积分
- 335
- 金钱
- 277
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
中级会员
- 积分
- 335
- 金钱
- 277
- HASS币
- 0
|
发表于 2023-8-9 12:39:47
|
显示全部楼层
const lenold = msg.payload;
const text = msg.warning.attributes.text;
const title = msg.warning.attributes.title;
const warningall = msg.warning.attributes.all;
const tsbtjl = msg.payload;
var len = '';
len = warningall.length;
var alert_content = [];
var xrtsbtjl = [];
for (var i = 0; i < Number(len); i++) {
if (tsbtjl.indexOf(`${warningall[i].pubTime}` + `${warningall[i].title}`) != -1) {
}
else {
alert_content.push({ 'id': i + 1, 'pubTime': `${warningall[i].pubTime}`, 'title': `${warningall[i].title}`, 'text': `${warningall[i].text}`, });
xrtsbtjl.push(`${warningall[i].pubTime}` + `${warningall[i].title}` + "丨");
}
}
msg.alert_content = alert_content;
msg.payload = tsbtjl + xrtsbtjl;
return msg;
这个函数运行后 总是提示:
function : (error)
"TypeError: Cannot read properties of undefined (reading 'length')"
这是怎么回事啊,求指导。 |
|