
p6004881
- 发布:2021-09-07 19:30
- 更新:2021-09-07 19:48
- 阅读:466
请问如何修改提示框的宽度,字太多被遮住了
分类:uni-app


formatter里判断字数然后加换行
这是我之前写的有点low,你可以参考一下
this.option.series[0].label.normal.formatter = function formatter(v) {
let text = v.name;
let value_format = v.value + '%';
if (text.length <= 6) {
return `${text}\n${value_format}`;
} else if (text.length > 6 && text.length <= 12) {
return text = `${text.slice(0, 6)}\n${text.slice(6)}\n${value_format}`
} else if (text.length > 12 && text.length <= 18) {
return text = `${text.slice(0, 6)}\n${text.slice(6, 12)}\n${text.slice(12)}\n${value_format}`
} else if (text.length > 18 && text.length <= 24) {
return text = `${text.slice(0, 6)}\n${text.slice(6, 12)}\n${text.slice(12, 18)}\n${text.slice(18)}\n${value_format}`
} else if (text.length > 24 && text.length <= 30) {
return text = `${text.slice(0, 6)}\n${text.slice(6, 12)}\n${text.slice(12, 18)}\n${text.slice(18, 24)}\n${text.slice(24)}\n${value_format}`
} else if (text.length > 30) {
return text = `${text.slice(0, 6)}\n${text.slice(6, 12)}\n${text.slice(12, 18)}\n${text.slice(18, 24)}\n${text.slice(24, 30)}\n${text.slice(30)}\n${value_format}`
}
}