本文整理匯總了TypeScript中virtual-dom.patch函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript patch函數的具體用法?TypeScript patch怎麽用?TypeScript patch使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了patch函數的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: originalPatch
const patch = (rdom: RDOM, patches: Patches): VDOM =>
originalPatch(rdom, patches);
示例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;
};