当调用最初在 public.common.js
中定义的 nopcommerce
的 displayBarNotification(stringIPass, 'success', 3500)
时,似乎调用失败当stringIPass
包含换行符
时。
客户端的错误类似于
Unexpected line break in a string literal
我尝试将ajax函数中的C#
换行符替换为等效的js,并且成功了。但是,出于可读性的原因,我打算保留“换行符”。您建议采取什么方法?
请原谅我缺少确切的错误表达式。但那是因为我目前不在工作。如果有必要,我明天会更新。
最佳答案
官方文档:
Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them.
使用反引号 (`) 引入模板文字:
var example = `
this
is
a
test
`;
console.log(example);
关于javascript - 将多行字符串作为参数传递给 js 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60194517/