相关疑难解决方法(0)

以HTML格式呈现字符串并保留空格和换行符

我有一个MVC3应用程序,它有一个详细信息页面.作为其中的一部分,我有一个描述(从数据库中检索)有空格和新行.渲染时,html会忽略新的行和空格.我想编码那些空格和新行,以便它们不被忽略.

你是怎样做的?

我尝试了HTML.Encode,但它最终显示了编码(甚至没有在空格和新行上,而是在其他一些特殊字符上)

html css whitespace newline line-breaks

197
推荐指数
5
解决办法
12万
查看次数

防止 ES6 模板字符串中的换行符

ESLint:403行超过最大行长120(max-len)

我有一个很长的字符串,我使用 ES6 模板字符串构建,但我希望它没有换行符:

var string = `Let me be the 'throws Exception’ to your 'public static void 
              main (String[] args)’. I will accept whatever you give me my ${love}.`
console.log(string);
Run Code Online (Sandbox Code Playgroud)

结果:

 Let me be the 'throws Exception’ to your 'public static void 
 main (String[] args)’. I will accept whatever you give me xxx.
Run Code Online (Sandbox Code Playgroud)

我的期望:

Let me be the 'throws Exception’ to your 'public static void main (String[] args)’. I will accept whatever you give me xxx.
Run Code Online (Sandbox Code Playgroud)

要求

  1. 我不能禁用 …

javascript ecmascript-6 template-strings

3
推荐指数
1
解决办法
3334
查看次数