<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Virtual DOMJavaScript DOM 模型

          聯(lián)合創(chuàng)作 · 2023-09-22 05:54

          Virtual DOM 是一個(gè) JavaScript DOM 模型,支持元素創(chuàng)建,區(qū)別計(jì)算和分支操作,提供高效的渲染。

          代碼示例

          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);
          瀏覽 15
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  欧美内射网站 | 激情五月婷婷丁香 | 日本黄色影视 | 含羞草自拍原创一区二区三区视频 | 欧美成人性做爱视频 |