Wrap long template literal line to multiline without creating a new line in the string

后端 未结 9 1415
谎友^
谎友^ 2020-12-01 02:40

In es6 template literals, how can one wrap a long template literal to multiline without creating a new line in the string?

For example, if you do this:



        
9条回答
  •  半阙折子戏
    2020-12-01 02:53

    Use the old and the new. Template literals are great but if you want to avoid lengthy literals so as to have compact lines of code, concatenate them and ESLint won't cause a fuss.

    const text = `a very long string that just continues`
      +` and continues and continues`;
    console.log(text);
    

提交回复
热议问题