我有这段代码:
for (var i = 0; i < value.length; i++) {
if (typeof value[i].keyword == 'undefined' || value[i].keyword == null || value[i].keyword.startsWith(keyword)) {
out.push(value[i]);
}
}
我收到一条错误消息:
> TypeError: r[e].startsWith is not a function > at js-cf2cc68….min.js.gz:85 > at fn (eval at compile (js-cf2cc68….min.js.gz:8), <anonymous>:4:1003) > at js-cf2cc68….min.js.gz:7 > at p.$digest (js-cf2cc68….min.js.gz:7) > at p.$apply (js-cf2cc68….min.js.gz:7) > at HTMLBodyElement.<anonymous> (js-cf2cc68….min.js.gz:9)
这怎么可能?我想我已经解释了一切。
原文由 Samantha J T Star 发布,翻译遵循 CC BY-SA 4.0 许可协议
value[i].keyword.startsWith("keyword")
因为start with的参数必须是字符串。这样会更好