【发布时间】:2019-06-19 10:50:09
【问题描述】:
我正在做一个项目,我需要从另一个函数调用一个变量,但我不知道如何调用它这里是我想从 HelloWorldIntentHandler 调用 team1、team2、server 的代码我该如何调用?
const HelloWorldIntentHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'HelloWorldIntent';
},
handle(handlerInput) {
var team1 = handlerInput.requestEnvelope.request.intent.slots.score.value;
var team2 = handlerInput.requestEnvelope.request.intent.slots.scoreone.value;
var server = handlerInput.requestEnvelope.request.intent.slots.scoretwo.value;
var value1 = Number(team1);
var value2 = Number(team2);
var totalteam1 = Math.round(value1 + value1 );
var totalteam2 = Math.round(value2 + value2 );
return handlerInput.responseBuilder
.speak("score is " + totalteam1)
.reprompt()
.getResponse();
}
};
const PickleballScoreNowHandler = {
canHandle(handlerInput) {
return handlerInput.requestEnvelope.request.type === 'IntentRequest'
&& handlerInput.requestEnvelope.request.intent.name === 'PickleballScoreNow';
},
handle(handlerInput) {
var team1 = handlerInput.requestEnvelope.request.intent.slots.score.value;
var team2 = handlerInput.requestEnvelope.request.intent.slots.scoreone.value;
var server = handlerInput.requestEnvelope.request.intent.slots.scoretwo.value;
return handlerInput.responseBuilder
.speak("score is " + team1 + team2 + server)
.reprompt()
.getResponse();
}
};
【问题讨论】:
-
你能否在更多解释中把问题说清楚一点?
标签: javascript node.js function logic alexa