我有一个非常长的字符串存储在属性文件中,它作为我网页上按钮的工具提示。
问题:我在我的xhtml中使用了属性文件,该密钥被评估为该长字符串,但是在新行的多个字符串中被破坏,因此浏览器发出错误,如
Uncaught SyntaxError: Invalid or unexpected token
因为评估如下:
function addTooltipForm1() {
var idsof = [ "Form 5558", "Automatic Extension", "DFVC Program", "Special Extension" ];
var tipTexts = ["Select this if you have filed an extension of time
to file form 5500 with the IRS using the completed Form
5558. (Employer should maintain a copy of the form 5558 with the filer’s record)."
}
在代码中,我用EL中的键写了它:
function addTooltipForm1() {
var idsof = [ "Form 5558", "Automatic Extension", "DFVC Program", "Special Extension" ];
var tipTexts = ["#{helpText5500['5500.identificationInformation.helpText.5558Form']}"];
addTooltipToEnums('#questionDOption', idsof, tipTexts);
}
显然是关键
#{helpText5500['5500.identificationInformation.helpText.5558Form']}
转换成
Select this if you have filed an extension of time
to file form 5500 with the IRS using the completed Form
这就是意外令牌的错误。
我尝试过使用模板文字,即反叛(`),但不适用于safari和Internet Explorer。
答案 0 :(得分:0)
您可以将模板文字用于多行字符串:
let tipTexts = [`Select this if you have filed an extension of time
to file form 5500 with the IRS using the completed Form
5558. (Employer should maintain a copy of the form 5558 with the filer’s record).`]
console.log(tipTexts);