launchRequest 的 alexa 处理程序语法
alexa handler syntax for launchRequest
我看到了这个示例代码,但不明白语法:
const newSessionHandler = {
LaunchRequest() {
this.handler.state = "ASKMODE";
this.emit(":ask", "Welcome to Custom Alexa skill, are you ready to begin?");
}
};
此处LaunchRequest
不是函数调用,也不是函数定义,因为没有关键字function
。那是什么?
我理解以下格式,其中 LaunchRequest
是一个键:
const newSessionHandler = {
LaunchRequest: function() {
this.handler.state = "ASKMODE";
this.emit(":ask", "Welcome to Custom Alexa skill, are you ready to begin?");
}
};
另一个问题: LaunchRequest
, NewSession
, unhandled all built-in events in nodejs alexa-sdk? alexa-sdk 中是否有所有内置事件的文档?
欢迎使用 ES 6,这是在对象中声明函数的新方法。
那里隐含地添加了function关键字。
了解有关 ES6 函数声明的更多信息,特别是使用显式“function”和 () => {}
之间的区别,其中您将遇到“[=19=”的问题]this'关键字。
在函数声明的新形式中 ()=>{},这将引用其父作用域而不是调用函数。
我看到了这个示例代码,但不明白语法:
const newSessionHandler = {
LaunchRequest() {
this.handler.state = "ASKMODE";
this.emit(":ask", "Welcome to Custom Alexa skill, are you ready to begin?");
}
};
此处LaunchRequest
不是函数调用,也不是函数定义,因为没有关键字function
。那是什么?
我理解以下格式,其中 LaunchRequest
是一个键:
const newSessionHandler = {
LaunchRequest: function() {
this.handler.state = "ASKMODE";
this.emit(":ask", "Welcome to Custom Alexa skill, are you ready to begin?");
}
};
另一个问题: LaunchRequest
, NewSession
, unhandled all built-in events in nodejs alexa-sdk? alexa-sdk 中是否有所有内置事件的文档?
欢迎使用 ES 6,这是在对象中声明函数的新方法。
那里隐含地添加了function关键字。
了解有关 ES6 函数声明的更多信息,特别是使用显式“function”和 () => {}
之间的区别,其中您将遇到“[=19=”的问题]this'关键字。
在函数声明的新形式中 ()=>{},这将引用其父作用域而不是调用函数。