你如何在浏览器中使用virtual-dom gist?

时间:2015-04-27 06:41:53

标签: javascript git dom

https://github.com/Matt-Esch/virtual-dom使用require()加载脚本,如果我想从浏览器中使用virtual-dom,如何设置?我尝试使用RequireJS [https://github.com/jrburke/requirejs]来处理require(),但它删除了我体内的所有脚本元素。警报永远不会发生。

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script src="https://raw.githubusercontent.com/volojs/create-template/master/www/lib/require.js"/>
</head>
<body>

<script> <!-- this script block gets removed by requireJS -->
alert(1);
// from the example at https://github.com/Matt-Esch/virtual-dom
var h = require('virtual-dom/h');    
var diff = require('virtual-dom/diff');
var patch = require('virtual-dom/patch');
var createElement = require('virtual-dom/create-element');
// 1: Create a function that declares what the DOM should look like
function render(count)  {
    return h('div', {
        style: {
            textAlign: 'center',
            lineHeight: (100 + count) + 'px',
            border: '1px solid red',
            width: (100 + count) + 'px',
            height: (100 + count) + 'px'
        }
    }, [String(count)]);
}
</script>
</body>
</html>

0 个答案:

没有答案