this.breakintoletters=()=>
this.lengthi!==0?(this.title2=this.title,this.title2.split(),this.title2.
map((x)=>this.arol.push(new letter(x))))
:!!false
基本上这就是代码。它应该将字符串分解为字母,然后将相关对象插入数组中。 检查字符串的长度,如果不是 0,则返回错误,其中 MAP 函数位于...) TypeError 告诉我它不是一个函数。编辑器没有显示错误。希望得到帮助
最佳答案
我建议使用不同的方法,提前检查 this.lengthi
并返回 false
,或者稍后返回推送值的映射长度。
this.breakintoletters = () => {
if (!this.lengthi) return false;
this.title2 = this.title;
// this.title2.split(); the result is not taken, not even splitted
return this.title2.map(x => this.arol.push(new letter(x)));
};
关于javascript - 为什么这个 JavaScript 对象方法返回 'not a function' 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55562015/