我希望能够在 switch case 语句上调用一个函数,但我似乎无法弄清楚。例子:
switch(message.toLowerCase()) {
// the startsWith would be an extension of the message.toLowerCase()
// so that the case would be checking for message.toLowerCase().startsWith("pay")
case startsWith("pay"):
console.log(message)
break
}
我试过使用 case.function()、function(case) 和 case function(),但它们都不起作用。谢谢!
呼啦一阵风
慕娘9325324
相关分类