在没有投影仪的情况下渲染马奎特 [英] Render Maquette without the Projector

查看:120
本文介绍了在没有投影仪的情况下渲染马奎特的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Maquette作为基本的上标语言.因此,我不想使用maquette.projector.但是,我很难使任何maquette.dom函数正常工作.

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>

我做错了什么?为什么dom.create不呈现任何内容?

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

推荐答案

很高兴看到您找到了没有投影仪的另一个用例. dom.create方法仅创建DOM节点,但不会将其附加到文档中的任何位置.您可以使用document.body.appendChild(root)dom.append(document.body, svg).

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).

这篇关于在没有投影仪的情况下渲染马奎特的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆