话不多说,直接上代码:
try {
_this.name.forEach((item, index) => {
if (item.name == _this.nameInfo) {
item.img = _this.canvas.toDataURL('image/png')
_this.isActive = index + 1;
} else {
_this.activeClick(item.name, _this.isActive);
throw new Error('end');//跳出循环
}
});
} catch (e) { }