Firstly, the color of a text is defined in the property fill
Then you need to use the set and renderAll functions.
Here is an example
var canvas = new fabric.Canvas("canvas");
var myText = new fabric.Text("Hello", {
top: 100,
left: 100,
width: 60,
height: 70,
fill: "red",
});
setTimeout(() => {
myText.set("fill", "green");
canvas.renderAll();
}, 2000);
canvas.add(myText);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…