setText(textORMap, forKey) {
let text = typeof textORMap === "string" ? textORMap : textORMap.text;
let size = (typeof textORMap === "object" ? textORMap.size : "14px") || "14px";
let family = (typeof textORMap === "object" ? textORMap.family : "") || "";
let color = (typeof textORMap === "object" ? textORMap.color : "#000000") || "#000000";
let offset = (typeof textORMap === "object" ? textORMap.offset : { x: 0.0, y: 0.0 }) || { x: 0.0, y: 0.0 };
this._dynamicText[forKey] = {
text,
style: `${size} family`,
color,
offset,
};
}
上面代码的 style:`${size} faimly` 并没有把 family当成变量写进去
改成 style:family && family!=="" ? `${size} ${family}` : `${size} family`;
试过直接写成style:`${size} ${family}`, 当family不传的时候,style = “xxpx ”,多了个空格,这样会导致style设置失效,包括fontsize