let node = new cc.Node();
node.addComponent(cc.Label);
let label = node.getComponent(cc.Label);
label.string = singleStr;
//_forceUpdateRenderData(); 2.2及后的版本
//_updateRenderData(true); 2.1及之前版本用的
(<any>label)._forceUpdateRenderData();
let width = label.node.getContentSize().width;
typescript+cocos creator label设置文本string后获取实际渲染宽高
于 2020-08-10 18:43:16 首次发布