按格式显示字体颜色

	  let str = '数字顺背:#&#FA9520@@【21854】#&'
		  function dealwith(str){
			  let res = str.replace(/#&(.+?)#&/g, function ($1){
				  console.log($1,"$1");
				  let [color, text] = $1.replace(/#&/g,'').split('@@');
				  console.log(color, text);
				  return `<span style={{color:${color}}}>${text}</span>`
			  })
			  console.log(res,"res")
			  return res
			  
		  }
		  document.write(dealwith(str))
posted @ 2021-08-26 17:15  橙云生  阅读(45)  评论(0编辑  收藏  举报