提交 158058f2 编写于 作者: Q qiang

fix: 回退安卓 measureText 功能

上级 3b7b5d79
......@@ -333,18 +333,9 @@ export class CanvasContext {
let width = 0
if (__PLATFORM__ === 'h5') {
width = measureText(text, font)
} else {
} else if (plus.os.name.toLowerCase() === 'ios') {
const webview = plus.webview.all().find(webview => webview.getURL().endsWith('www/__uniappview.html'))
if (webview) {
for (let index = 0; index < 5; index++) {
width = Number(webview.evalJSSync(`(${measureText.toString()})(${JSON.stringify(text)},${JSON.stringify(font)})`))
// 安卓部分情况会计算失败,进行重试
if (!isNaN(width)) {
width = 0
break
}
}
}
width = Number(webview.evalJSSync(`(${measureText.toString()})(${JSON.stringify(text)},${JSON.stringify(font)})`))
}
return new TextMetrics(width)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册