Javascript 中的 Alexa 词典
Dictionaries in Javascript for Alexa
我正在使用 javascript(特别是 Node.js)构建 Alexa 技能,但我 运行 陷入了一个我不明白的错误。一、代码:
"use strict";
var Alexa = require("alexa-sdk");
var handlers = {
"LaunchRequest": function () {
this.response.speak(content[one]).listen(content[oneNext]);
this.emit(':responseReady');
},
"TwoIntent": function() {
this.response.speak(content[two]).listen(content[twoNext]);
this.emit(':responseReady');
}
};
var content = {
one: 'text',
oneNext: 'text',
two:'text',
twoNext: 'text',
three: 'text',
threeNext: 'text',
four: 'text',
fourNext: 'text',
five: 'text',
};
// Stock Alexa Handlers & Functions
exports.handler = function(event, context, callback){
var alexa = Alexa.handler(event, context);
alexa.registerHandlers(handlers);
alexa.execute();
};
我在 Lambda 界面中遇到的错误是:"one is not defined. please fix or add /global one/ "
根据我能找到的关于如何在 javascript 中创建字典的所有文档,此语法是正确的。这是 alexa 或 lambda 特有的吗?
使用 content.one
和 content.oneNext
以及 content.two
和 content.twoNext
而不是 content[one]
。或者可能 content["one"]
...这是替代语法。
我正在使用 javascript(特别是 Node.js)构建 Alexa 技能,但我 运行 陷入了一个我不明白的错误。一、代码:
"use strict";
var Alexa = require("alexa-sdk");
var handlers = {
"LaunchRequest": function () {
this.response.speak(content[one]).listen(content[oneNext]);
this.emit(':responseReady');
},
"TwoIntent": function() {
this.response.speak(content[two]).listen(content[twoNext]);
this.emit(':responseReady');
}
};
var content = {
one: 'text',
oneNext: 'text',
two:'text',
twoNext: 'text',
three: 'text',
threeNext: 'text',
four: 'text',
fourNext: 'text',
five: 'text',
};
// Stock Alexa Handlers & Functions
exports.handler = function(event, context, callback){
var alexa = Alexa.handler(event, context);
alexa.registerHandlers(handlers);
alexa.execute();
};
我在 Lambda 界面中遇到的错误是:"one is not defined. please fix or add /global one/ "
根据我能找到的关于如何在 javascript 中创建字典的所有文档,此语法是正确的。这是 alexa 或 lambda 特有的吗?
使用 content.one
和 content.oneNext
以及 content.two
和 content.twoNext
而不是 content[one]
。或者可能 content["one"]
...这是替代语法。