angular - 如何将此字符串转换为模板文字
问题描述
我想将下面的字符串转换为模板文字。谁能帮我
public readonly defaultSvgIcon:string = "<svg aria-hidden=\"true\" focusable=\"false\""+
"data-prefix=\"fas\" data-icon=\"external-link-alt\" class=\"svg-inline--fa fa-external-link-alt fa-w-16\""+
"role=\"img\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><path fill=\"currentColor\""+
"d=\"M432,320H400a16,16,0,0,0-16,16V448H64V128H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V336A16,16,0,0,0,432,320ZM488,0h-128c-21.37,0-32.05,25.91-17,41l35.73,35.73L135,320.37a24,24,0,0,0,0,34L157.67,377a24,24,0,0,0,34,0L435.28,133.32,471,169c15,15,41,4.5,41-17V24A24,24,0,0,0,488,0Z\">"+
"</path></svg>"
我尝试了下面的代码,但它抛出错误:
"<svg aria-hidden=`true` focusable=`false`"+
"data-prefix=`fas` data-icon=`external-link-alt` class=`svg-inline--fa fa-external-link-alt fa-w-16`"+
"role=`img` xmlns=`http://www.w3.org/2000/svg` viewBox=`0 0 512 512`><path fill=`currentColor`"+
"d=`M432,320H400a16,16,0,0,0-16,16V448H64V128H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V336A16,16,0,0,0,432,320ZM488,0h-128c-21.37,0-32.05,25.91-17,41l35.73,35.73L135,320.37a24,24,0,0,0,0,34L157.67,377a24,24,0,0,0,34,0L435.28,133.32,471,169c15,15,41,4.5,41-17V24A24,24,0,0,0,488,0Z`>"+
"</path></svg>"
解决方案
用这个
public readonly defaultSvgIcon:string = `your whole svg code lines without escaping esacaping special character`
推荐阅读
- r - 为什么我不能在 RStudio 中安装 Plotly 包?错误说明了什么?
- javascript - 2个错误:(未捕获的ReferenceError:未定义要求)&(npm ERR!缺少脚本:开始)
- r - 需要帮助重新订购月份
- elasticsearch - Elasticsearch如何在重新索引时删除字段
- calculator - Yacc 计算器括号和指数问题
- python - 在类的各种底层实现之间进行选择
- python - 在 Python 上运行多个 If-Loop 用于音乐制作?
- reactjs - 使用 React.lazy 动态选择组件
- amazon-web-services - Lambda 无权访问 ECR 映像
- r - 使用 apriori() 从规则对象中提取 transactionID