function queue_instructions(){
var input_message = "Commands
w? Shows whos on the waitlist
w+ Adds yourself to the waitlist
w- Removes yourself from the waitlist
w++ Moves yourself down one spot on the waitlist
-mods Shows a list of available moderators
-plays Shows how many songs each DJ has played
-promote Requests a vote from everyone for you to be moved to 1st on the list
-pull [#] Requests a vote from everyone to pull that DJ off the booth Number of DJ is what number spot he is on the booth Numbers read from left to right
-remove [#] Removes that number DJ from the waitlist Must be a moderator
-votekick [username] Requests a vote from everyone to kick the user
Type -help [command] for more info on a command (ie. -help w?)";
deliver_chat(input_message);
我在Google Chrome上的Javascript控制台上收到语法错误意外令牌非法。有什么想法吗?
答案 0 :(得分:3)
您必须在每一行上关闭这些引号,并与+
连接到下一行:
var input_message = "Commands " +
"w? Shows whos on the waitlist " +
"w+ Adds yourself to the waitlist " +
等等
您是否希望每行都插入换行符?如果是这样,您可以使用\n
:
var input_message = "Commands\n" +
"w? Shows whos on the waitlist\n" +
"w+ Adds yourself to the waitlist\n" +
答案 1 :(得分:1)
将字符串拆分为多行时,需要将其与+
连接起来
var input_message = "Commands"+
"w? Shows whos on the waitlist"+
"w+ Adds yourself to the waitlist"+
"w- Removes yourself from the waitlist"+
"w++ Moves yourself down one spot on the waitlist"+
"-mods Shows a list of available moderators"+
"-plays Shows how many songs each DJ has played"+;
而且在你的代码中,我找不到该函数的结束大括号}
。
function queue_instructions()
{
//Stuff here.
}
你需要加入它。
答案 2 :(得分:0)
您的语法不正确。您需要将整个字符串放在一行中,或者在每行中关闭引号,然后执行a +以连接下一行。
答案 3 :(得分:0)
或者你喜欢这样:
var input_message = [
"Commands",
"w? Shows whos on the waitlist",
"w+ Adds yourself to the waitlist",
"w- Removes yourself from the waitlist",
"w++ Moves yourself down one spot on the waitlist",
"-mods Shows a list of available moderators",
"-plays Shows how many songs each DJ has played",
"-promote Requests a vote from everyone for you to be moved to 1st on the list",
"-pull [#] Requests a vote from everyone to pull that DJ off the booth Number of DJ is what number spot he is on the booth Numbers read from left to right",
"-remove [#] Removes that number DJ from the waitlist Must be a moderator",
"-votekick [username] Requests a vote from everyone to kick the user",
"Type -help [command] for more info on a command (ie. -help w?)"
].join("\n");
答案 4 :(得分:0)
我注意到没有人建议逃避行尾:
var multiStr = "This is the first line \
This is the second line \
This is more...";
请注意,行结尾包含在此字符串中......