這個字符串變量在js中定義。Es6格式錯誤?
bodycontent = 'Hello ' + studentName + '%0D%0AThe course ' + courseName
+ ' is using the TEAMMATES System to collect feedback.%0D%'
+ '0ATo \'join\' the course, please go to this Web address: '
+ encodeURIComponent(uri) + '%0D%0A*If prompted to log in, '
+ 'use your Googleaccount to log in. If you do not '
+ 'have a Google account, please create one from the '
+ encodeURIComponent('https://accounts.google.com/NewAccount')
+ '%0D%0A*The above link is unique to you. Please do not '
+ 'share it with your classmates.%0D%0ANote that If you '
+ 'wish to access TEAMMATES without using your Googleaccount, '
+ 'you do not need to \'join\' the course as instructed '
+ 'above. You will still be able to submit/view feedback '
+ 'by following the instructions sent to you by TEAMMATES at the '
+ 'appropriate times. However, we recommend joining the courseusing '
+ 'your Google account, because it gives you more convenient '
+ 'access to all your feedback stored in TEAMMATES.%0D%0A%0D%0A'
+ 'If you encounter any problems when using the system, you can '
+ 'email TEAMMATES support team at [email protected]%0D%0A%0D%0A'
+ 'Regards,%0D%0ATEAMMATES Team.';
對於一行中超過125個字符,我使用+將它分成下一行現在問題是當我將其轉換爲ES6時。
bodycontent = `Hello ${studentName}%0D%0AThe following feedback session is ${status}%0D%0A`
+ `Course: [${Id}]${courseName}%0D%0AFeedback Session Name: ${Id}%0D%0A`
+ `The link of the feedback for the above session, please go to this Web `
+ `address: ${encodeURIComponent(uri)}%0D%0A*The above link is unique to you.`
+ `Please do not share it with others.%0D%0A%0D%0AIf you encounter any problems`
+ `when using the system, you can email TEAMMATES support team at [email protected]%0D%0A%0D%0ARegards,%0D%0ATEAMMATES Team.`;
這表明我錯誤「字符串必須使用單引號」在每行不包含變量。
我能打破這樣也行
bodycontent = `Hello ${studentName}%0D%0AThe following feedback session is ${status}%0D%0A
Course: [${Id}]${courseName}%0D%0AFeedback Session Name: ${Id}%0D%0A
The link of the feedback for the above session, please go to this Web
address: ${encodeURIComponent(uri)}%0D%0A*The above link is unique to you.`
......
但問題是,我得到「\ n」除了在我的字符串換行,我不想好心告訴我有效的方式來打破該行沒有在我的字符串中添加\ n。