bixby - 如何为新用户提供不同的结果视图
问题描述
如何为新用户提供不同的结果视图消息或布局?
在这种情况下,我希望视图根据用户是否为新用户而有所不同,如 UserData 概念所示,我在操作 GetAltBrainsData 中计算其值。我已经为 UserData 提供了存储的功能配置文件。
result-view {
match: AltBrainsData (this)
{
from-output: GetAltBrainsData (getaltbrainsdata)
}
message {
//here is where i want to check if UserData.newuser = true and vary the answer
//if (userdata.newuser) {template("hello new user")} else ...
if (size(this) > 1) {
template ("I found #{(size(this))} AltBrains")
}
else-if (size(this) == 1 ) {
template ("") {speech ("#{value(this.name)}")}
}
else {template ("No AltBrains matched the search.")}
}
render {
// if UserData.newuser = true then welcome layout
但结果视图似乎仍然不知道 UserData。IDE 抱怨它是 userdata.newuser 中的非法表达式
解决方案
试试if (getaltbrainsdata.userdata.newuser)
,或者你UserData
在你的动作模型中命名的任何东西。
解决此问题的另一种方法是使用匹配模式访问它,例如
result-view {
match: AltBrainsData (this)
{
from-output: GetAltBrainsData (getaltbrainsdata) {
from-input: UserData (userData)
}
...
推荐阅读
- javascript - 仅在异步代码块完成后如何访问 JavaScript 中的全局变量
- angular - patchValue 现在正在初始化 FormArray 值
- angular - CORS Chrome通配符'*'Angular 8?
- android - Android viewPager - 需要从 JSON 加载图像
- amazon-web-services - 如何获取 CloudFormation 生成的 lambda 的日志组名称和 ARN?
- sas - 为 %sysget 返回值设置默认值
- django - 如何根据 Django 中的单选按钮呈现查询集
- windows - Docker for Windows 无法拉取私有镜像。错误是“上下文已取消”
- java - 在 Java 线程代码中“忽略新实例”警告
- javascript - 从 vb.net 中 json 文件的数组中返回多个元素,绑定到数据表