How to count the width of a line of Chinese characters in a label

know the width and height of a label, the text size is fixed at 20px, and use JS to count the text width of each line.

Mar.24,2021

1. Get DOM
2. Get DOM.innerHTML
3. Get the length of innerHTML (number of words)
4. The number of words * 20px is the width. See if the result is the
5 you want. Fine-tuning.

Menu