本文整理匯總了TypeScript中virtual-dom/h.h函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript h函數的具體用法?TypeScript h怎麽用?TypeScript h使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了h函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: renderPosts
function renderPosts(posts: Pair<PostInfo, PostContent>[]): Html {
return h(
"div",
{},
posts.map(p =>
h("div", {}, [h("h2", {}, String(p[0].date)), h("div", {}, p[1])])
)
);
}
示例2: renderTopics
function renderTopics(topics: { [word: string]: number }): Html {
return h(
"ul",
{},
Object.keys(topics).map(topic => {
return h("li", {}, `${topic} - ${topics[topic]}`);
})
);
}
示例3: renderPage
function renderPage(left: Html, main: Html): Html {
return h("div", { style: { display: "flex" } }, [
h("div#left", { style: { width: 200 } }, [left]),
h("div#main", { style: { flex: 2 } }, [main]),
]);
}
示例4: h
posts.map(p =>
h("div", {}, [h("h2", {}, String(p[0].date)), h("div", {}, p[1])])
示例5: renderPostList
function renderPostList(posts: Pair<PostInfo, PostContent>[]): Html {
return h("ul", {}, posts.map(p => h("li", {}, p[1])));
}
示例6: renderSidePane
function renderSidePane(popular: Html, topics: Html): Html {
return h("section", {}, [
h("div#popular", {}, [h("h2", {}, "Popular"), popular]),
h("div#topics", {}, [h("h2", {}, "Topics"), topics]),
]);
}