该问题的解决方法是使用以下代码将视口传递给请求:
handlerInput.responseBuilder
.withShouldEndSession(false)
.addDirective({
type: 'Alexa.Presentation.APL.RenderDocument',
version: '1.0',
document: yourDocument,
datasources: yourDataSource,
token: 'yourToken',
//here is the viewport parameter
targetViewport: {
//check Alexa documentation for optimal values according to your layout
size: {
width: 1024,
height: 600
},
dpi: 160,
shape: 'RECTANGLE',
pixelWidth: 1024,
pixelHeight: 600,
currentPixelWidth: 1024,
currentPixelHeight: 600,
touch: [
{
x: 0,
y: 0
}
]
}
});
以上是传递视口参数的示例代码,其中包含了Alexa.Presentation.APL.RenderDocument 的内置指令。这样,请求将传递视口并正确执行。