Aframe 在框架中带有图像和标题的鼠标悬停
当鼠标移动到帧中的图像上时,我希望显示一个图像和一个标题。要将鼠标用作光标,请使用Aframe 在框架中带有图像和标题的鼠标悬停,aframe,Aframe,当鼠标移动到帧中的图像上时,我希望显示一个图像和一个标题。要将鼠标用作光标,请使用您需要将mouseentereventlistener添加到对象中 HTML 当然,您可以将HTML换成框架中的任何基本内容,只要您保留id,它就可以工作 <a-entity id="parent" listener> <a-entity id="images_and_captions"></a-entity> </a-entity> AFRAME.reg
您需要将mouseenter
eventlistener
添加到对象中
HTML
当然,您可以将HTML换成框架中的任何基本内容,只要您保留id,它就可以工作
<a-entity id="parent" listener>
<a-entity id="images_and_captions"></a-entity>
</a-entity>
AFRAME.registerComponent('listener', {
init: function() {
this.el.addEventListener('mouseenter', (e) => {
this.el.children[0].setAttribute('visible', 'true');
})
this.el.addEventListener('mouseleave', (e) => {
this.el.children[0].setAttribute('visible', 'false');
})
}
})
<img alt="img" id="img" src="myimg"/>
window.onload = function(){
var img = document.getElementById("img");
img.addEventListener("mouseenter", function(){
//your code to show image and text here
});
}