文件名称:JavaScriptDOM模型VirtualDOM.zip
文件大小:81KB
文件格式:ZIP
更新时间:2022-08-05 22:07:53
开源项目
Virtual DOM 是一个 JavaScript 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)]); } // 2: Initialise the document var count = 0; // We need some app data. Here we just store a count. var tree = render(count); // We need an initial tree var rootNode = createElement(tree); // Create an initial root DOM node ... document.body.appendChild(rootNode); // ... and it should be in the document // 3: Wire up the update logic setInterval(function () { count ; var newTree = render(count); var patches = diff(tree, newTree); rootNode = patch(rootNode, patches); tree = newTree; }, 1000); 标签:Virtual
【文件预览】:
virtual-dom-master
----.jshintrc(866B)
----diff.js(61B)
----docs.jsig(5KB)
----.zuul.yml(399B)
----h.js(70B)
----create-element.js(88B)
----vtree()
--------diff.js(12KB)
--------test()
--------README.md(647B)
--------diff-props.js(1KB)
----patch.js(63B)
----.travis.yml(557B)
----LICENSE(1KB)
----test()
--------thunk.js(2KB)
--------main.js(28KB)
--------sort.js(6KB)
--------hook.js(13KB)
--------lib()
--------style.js(1KB)
--------undefined-properties.js(4KB)
--------non-string.js(611B)
--------nested-properties.js(4KB)
--------index.js(347B)
--------keys.js(22KB)
--------attributes.js(2KB)
----README.md(8KB)
----vdom()
--------apply-properties.js(3KB)
--------update-widget.js(313B)
--------create-element.js(1KB)
--------dom-index.js(2KB)
--------patch-op.js(4KB)
--------patch.js(2KB)
--------test()
--------README.md(880B)
----dist()
--------virtual-dom.js(45KB)
----docs()
--------vnode.md(6KB)
--------widget.md(3KB)
--------vtext.md(1KB)
--------hooks.md(2KB)
--------README.md(2KB)
--------faq.md(3KB)
--------css-animations.md(3KB)
--------thunk.md(6KB)
----vnode()
--------is-vnode.js(164B)
--------vpatch.js(485B)
--------is-widget.js(88B)
--------handle-thunk.js(834B)
--------vtext.js(210B)
--------is-vtext.js(164B)
--------test()
--------is-thunk.js(90B)
--------is-vhook.js(220B)
--------vnode.js(2KB)
--------version.js(21B)
----.editorconfig(207B)
----.gitignore(164B)
----index.js(352B)
----CHANGELOG.md(2KB)
----virtual-hyperscript()
--------parse-tag.js(1KB)
--------test()
--------README.md(2KB)
--------svg-attribute-namespace.js(11KB)
--------svg.js(1KB)
--------hooks()
--------index.js(4KB)
----package.json(2KB)