Render Maquette without the Projector

陌路散爱 提交于 2020-01-06 19:51:29

问题


I want to use Maquette as a basic hyperscript language. Consequently, I don't want to use the maquette.projector. However, I'm having a hard time getting any of the maquette.dom functions to work.

var h = maquette.h;
var dom = maquette.dom;
var svg = h('div.sweet', [
  h('svg', [
    h('circle', { cx: '2cm', cy: '2cm', r: '4cm', fill: 'red' }),
  ])
]);

document.addEventListener('DOMContentLoaded', function () {
  console.log(svg);
  var root = dom.create(svg).domNode;
});
<script src="//cdnjs.cloudflare.com/ajax/libs/maquette/2.4.1/maquette.min.js"></script>

What am I doing wrong? Why is dom.create not rendering anything?


回答1:


Nice to see that you have found another usecase without the projector. The dom.create method only creates the DOM nodes, but it does not append them anywhere in the document. You can use document.body.appendChild(root) or use dom.append(document.body, svg).



来源:https://stackoverflow.com/questions/41790651/render-maquette-without-the-projector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!