AFrame 内容未使用 hyperHTML 在 Chrome 上呈现
AFrame content not rendering on Chrome with hyperHTML
A-Frame 内容在 FireFox 和 Safari 上呈现时不会在 Chrome 上呈现。
根据CodePen here
const { hyper, wire } = 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>
`;
}
}
document.body.appendChild(new Box().render());
我确定我遗漏了一些东西,相同的内容在所有浏览器中都可以呈现为静态 HTML (CodePen)。
<body>
<a-scene>
<a-box color="red" position="0 2 -5" rotation="0 45 45" scale="2 2 2"></a-box>
</a-scene>
</body>
更新:我已经在 hyperHTML 中强制修复了这个问题,即使它是关于使用自定义元素 V0 的 AFrame。一旦 AFrame 迁移到 V1,我将放弃强制修复。
你的代码笔,我的也是,现在可以使用了。此致
我已经 forked your pen 编写了几乎相同的代码:
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}`;
但我不得不在最后添加一个非常难看的行:
// if you comment this out nothing works
document.body.innerHTML = document.body.innerHTML;
这是因为 AFrame 使用自定义元素 polyfill(实际上是我的),当它从模板节点克隆时似乎不会触发注册表。
有 a polyfill known issue 我从未能够重现,这可能是我正在寻找的用例。
不幸的是,现在 AFrame 组件似乎在使用 hyperHTML 时可能会遇到问题。
抱歉,我会尽快解决这个问题。
澄清一下误会,经证实这不是 hyperHTML 错误。
编写以下内容
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 存储库中更新 bug filed
A-Frame 内容在 FireFox 和 Safari 上呈现时不会在 Chrome 上呈现。
根据CodePen here const { hyper, wire } = 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>
`;
}
}
document.body.appendChild(new Box().render());
我确定我遗漏了一些东西,相同的内容在所有浏览器中都可以呈现为静态 HTML (CodePen)。
<body>
<a-scene>
<a-box color="red" position="0 2 -5" rotation="0 45 45" scale="2 2 2"></a-box>
</a-scene>
</body>
更新:我已经在 hyperHTML 中强制修复了这个问题,即使它是关于使用自定义元素 V0 的 AFrame。一旦 AFrame 迁移到 V1,我将放弃强制修复。
你的代码笔,我的也是,现在可以使用了。此致
我已经 forked your pen 编写了几乎相同的代码:
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}`;
但我不得不在最后添加一个非常难看的行:
// if you comment this out nothing works
document.body.innerHTML = document.body.innerHTML;
这是因为 AFrame 使用自定义元素 polyfill(实际上是我的),当它从模板节点克隆时似乎不会触发注册表。
有 a polyfill known issue 我从未能够重现,这可能是我正在寻找的用例。
不幸的是,现在 AFrame 组件似乎在使用 hyperHTML 时可能会遇到问题。
抱歉,我会尽快解决这个问题。
澄清一下误会,经证实这不是 hyperHTML 错误。
编写以下内容
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 存储库中更新 bug filed