cocos create 2.x 文本的宽度要下一帧才能获取,如何才能提前获取

let label = this.node.getChildByName(“label”);//原始label的string为“Label”
console.log(“1:==>” +label.getContentSize().width);
label.getComponent(cc.Label).string = “1”;
console.log(“2:==>” +label.getContentSize().width);
this.scheduleOnce(function() {
let label = this.node.getChildByName(“label”);
console.log(“3:==>” +label.getContentSize().width);
label.getComponent(cc.Label).string = “11”;
console.log(“4:==>” +label.getContentSize().width);
}.bind(this), 0);

    this.scheduleOnce(function() {
        let label = this.node.getChildByName("label");
        console.log("5:==>" +label.getContentSize().width);
    }.bind(this), 1);

打印结果:
Simulator: D/jswrapper (129): JS: 1:==>97.87
Simulator: D/jswrapper (129): JS: 2:==>97.87
Simulator: D/jswrapper (129): JS: 3:==>22
Simulator: D/jswrapper (129): JS: 4:==>22
Simulator: D/jswrapper (129): JS: 5:==>41

你主动调用label节点的update一次试试