meteor - Aframe + Meteor - 向实体添加条件自定义组件
问题描述
解决方案
已解决这是我的原件,它不起作用。
在 main.js 中:
player = "player not active";
Template.hello.helpers(
counter() {......
// if player one
player = "playerone";
// if player two
player = "playertwo";
return { myplayer: player };
}
在 main.html 中:
// This statement works
{{counter.myplayer}}....
<a-gltf-model id='playerone' class="{{#if counter.myplayer playerone}}entitymove{{/if}}" src="#myMixBun"> </a-gltf-model>
<a-gltf-model id='playertwo' class="{{#if counter.myplayer playertwo}}entitymove{{/if}}" src="#myMixBun"> </a-gltf-model>
我认为这有两个问题:
1)空格键似乎不喜欢带有比较的if语句?:
{{#if counter.myplayer playertwo}}
它只允许 true 或 false if 语句?,例如:
{{#if counter.player1}}
2)我的 aframe 自定义组件实际上不是一个类,所以我不能将流星 #if 语句放在实体中。
我将代码更改为以下内容,现在可以使用:
将 main.js 更改为:
playerone ="";
playertwo ="";
// if player one
playerone = "true";
playertwo = "";
// if player two
playerone = "";
playertwo = "true";
return { player1: playerone, player2: playertwo};
}
将 main.html 更改为:
// These statements work
{{#if counter.player1}}player1 is true{{/if}}
{{#if counter.player2}}player2 is true{{/if}}....
{{#if counter.player1}}
<a-gltf-model id='playerone' entitymove src="#myMixBun" ></a-gltf-model>
<a-gltf-model id='playertwo' src="#myMixBun" ></a-gltf-model>
{{/if}}
{{#if counter.player2}}
<a-gltf-model id='playerone' src="#myMixBun" ></a-gltf-model>
<a-gltf-model id='playertwo' entitymove src="#myMixBun" ></a-gltf-model>
{{/if}}
推荐阅读
- cmd - 如何查询然后杀死批处理文件中的服务(新手)
- python - NumPy 中的索引:访问每组其他值
- mysql - 仅为用户或数据库禁用 ONLY_FULL_GROUP_BY MySQL 模式
- java - 选择所有在休眠状态下不起作用的查询
- azure - 在 azurerm_automation_account 中寻找可选 sku 变量的 terraform 模块参考
- python - 如何在python3中获取protobuf的RepeatedCompositeContainer或RepeatedScalarContainer包含的类型?
- php - 使用 preg_match 您可以剪切不同句子的特定部分
- python - 在 Django 中过滤查询集的子集
- azure - 如何在 Azure 中的数据盘上配置文件系统?
- apache-kafka - 确保已使用 REST 代理从 Kafka 主题读取所有消息