React.js 修改文本中数字样式
export function numberToColor(text, color = '#635BFF', size = '12px') { let reg = /(\d+)/g; return text.replace(reg, `<span style="color: ${color};size: ${size}">$1</span>`); }
效果:
export function numberToColor(text, color = '#635BFF', size = '12px') { let reg = /(\d+)/g; return text.replace(reg, `<span style="color: ${color};size: ${size}">$1</span>`); }
效果: