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

后端 未结 9 1422
谎友^
谎友^ 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 03:15

    The solution proposed by @CodingIntrigue is not working for me on node 7. Well, it works if I do not use a line continuation on the first line, it fails otherwise.

    This is probably not the best solution, but it works without problems:

    (`
        border:1px solid blue;
        border-radius:10px;
        padding: 14px 25px;
        text-decoration:none;
        display: inline-block;
        text-align: center;`).replace(/\n/g,'').trim();
    

提交回复
热议问题