Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Aframe 在框架中带有图像和标题的鼠标悬停_Aframe - Fatal编程技术网

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
  });
}