-1

Please see the following images. These codes for vue js. The inline codes as the first image is working. But when put returns, as the second image, the codes are not working. But the codes all same in both images, only difference is multi lines. These images from Sublime Text Editor, but all the same happened in Atom and Notepad++ too.

Any suggestion why this happening!

Codes are ok Codes are notOk

Charlie Fish
  • 18,491
  • 19
  • 86
  • 179
Bulbul Anwar
  • 51
  • 1
  • 8
  • In the second case, you need to use multiline string syntax: https://stackoverflow.com/questions/805107/creating-multiline-strings-in-javascript#805113 – dvnguyen Dec 25 '17 at 06:57

1 Answers1

1

If you add \ to the end of each new line that will tell the string to go to the next line. You could use the new string literal syntax in ES6. For example in ES6 (notice the ` instead of quotes).

var my_string = `some other
cool
thing`

If you aren't able to use ES6 you can do the same thing using the \.

var my_string = "some other\
cool\
thing"

Finally you could just add the strings together.

var my_string = 'Lorem ipsum dolor sit amet, ' +  
    'consectetur adipiscing elit, sed do eiusmod tempor ' +
    'incididunt ut labore et dolore magna aliqua. Ut enim' +
    ' ad minim veniam'
Charlie Fish
  • 18,491
  • 19
  • 86
  • 179