A-Frame完全加载时是否会触发某些事件?现在我已经设法让我的document.querySelector(".a-enter-vr-button")
工作,但只有在将它放在一个setTimeout
函数之后,这似乎是一个临时解决方案.因此,如果任何人有任何方法在A-Frame完全加载后使js脚本生效,请告诉我!
你可以使用这个loaded
活动:
document.querySelector('a-scene').addEventListener('loaded', function () {...})
但我们建议您使用组件,这样您就不必处理等待事件设置的事件:
AFRAME.registerComponent('log', {
schema: {type: 'string'},
init: function () {
var stringToLog = this.data;
console.log(stringToLog);
}
});
Run Code Online (Sandbox Code Playgroud)
然后使用HTML中的组件:
<a-scene log="Hello, Scene!">
<a-box log="Hello, Box!"></a-box>
</a-scene>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3734 次 |
最近记录: |