本文整理汇总了TypeScript中virtual-dom.diff函数的典型用法代码示例。如果您正苦于以下问题:TypeScript diff函数的具体用法?TypeScript diff怎么用?TypeScript diff使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了diff函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: appendPosts
private appendPosts(): void {
let newCollectionNode = new PostCollectionView(this.loadedPosts).render();
if (!this.collectionElement) {
this.collectionElement = create(newCollectionNode);
let postElements = this.element.querySelectorAll(".post");
let lastElement = postElements[postElements.length - 1];
if (lastElement && lastElement.parentElement) {
lastElement.parentElement.insertBefore(
this.collectionElement,
lastElement.nextSibling,
);
}
} else {
let patches = diff(this.collectionNode, newCollectionNode);
this.collectionElement = patch(this.collectionElement, patches);
}
this.collectionNode = newCollectionNode;
}
示例2: originalDiff
const diff = (current: VDOM, next: VDOM): Patches =>
originalDiff(current, next);
示例3: render
stores[storeName].subscribe(() => {
let newTree = render(stores);
let patches = diff(tree, newTree);
rootNode = patch(rootNode, patches);
tree = newTree;
})
示例4: diff
const updateDom = (newTree: VirtualDOM.VNode): void => {
const patches: VPatch[] = diff(currentTree, newTree);
rootNode = patch(rootNode, patches);
currentTree = newTree;
};