首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AFrame内容不使用hyperHTML在Chrome上呈现

AFrame内容不使用hyperHTML在Chrome上呈现
EN

Stack Overflow用户
提问于 2017-10-17 19:18:33
回答 2查看 210关注 0票数 1

A帧内容在Chrome上不呈现,而在FireFox和Safari上呈现。

根据CodePen在这里 const { hyper,钢丝}= hyperHTML;

代码语言:javascript
复制
class Box extends hyper.Component {

  render() { return this.html`
    <a-scene>
        <a-box color="red" position="0 2 -5" rotation="0 45 45" scale="2 2 2"></a-box>
    </a-scene>
  `;
  }
}

document.body.appendChild(new Box().render());

我确信我遗漏了一些东西,在所有浏览器(CodePen)中,同样的内容呈现得与静态HTML一样好。

代码语言:javascript
复制
<body>
  <a-scene>
    <a-box color="red" position="0 2 -5" rotation="0 45 45" scale="2 2 2"></a-box>
  </a-scene>
</body>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-10-18 19:01:27

Update:我已经强制-修复了hyperHTML中的问题,即使它是关于AFrame uaing Custom V0的。一旦AFrame迁移到V1,我将放弃强制修复。

你的密码笔,还有我的,现在起作用了。问候

我已经编写了分叉你的钢笔并编写了几乎相同的代码:

代码语言:javascript
复制
const { hyper } = hyperHTML;

class Box extends hyper.Component {
  render() { return this.html`
    <a-scene>
          <a-box color="red"
            position="0 2 -5"
            rotation="0 45 45"
            scale="2 2 2"></a-box>
        </a-scene>`;
  }
}

hyper(document.body)`${new Box}`;

但我不得不在结尾加上一句非常丑陋的话:

代码语言:javascript
复制
// if you comment this out nothing works
document.body.innerHTML = document.body.innerHTML;

这是因为AFrame使用了一个自定义元素polyfill (实际上是我的),当从模板节点克隆它时,它似乎不会触发注册表。

有一个一个已知的问题,我从来没有能够复制,这可能是我正在寻找的用例。

不幸的是,现在看来,AFrame组件在使用hyperHTML时可能会遇到麻烦。

抱歉,我会尽快解决这个问题的。

票数 1
EN

Stack Overflow用户

发布于 2017-10-20 18:40:25

为了澄清误解,已经证实这不是一个hyperHTML错误。

编写以下内容

代码语言:javascript
复制
const scene = `<a-scene>
  <a-box color="red" position="0 2 -5" rotation="0 45 45" scale="2 2 2"></a-box>
</a-scene>`;

var template = document.createElement('template');
template.innerHTML = scene;
document.body.appendChild(template.content);

如果不包括AFrame之外的任何额外库,也会失败。

有一个正在进行的调查,但您应该注意的是,任何基于现代模板元素的库,以产生通用内容将失败的aframe 0.7和仅在Chrome。

更新 臭虫档案在AFrame存储库中

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46797635

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档