htm

编程之家收集整理的这个编程导航主要介绍了htm编程之家,现在分享给大家,也给大家做个参考。

htm

htm 介绍

htm 实际上将jsX风格的语法更进一步!htm适用于大多数Virtual DOM库 .

npm安装:

npm i htm

import htm from 'https://unpkg.com/htm?module'

const html = htm.bind(react.createElement);

// just want htm + preact in a single file? there's a highly-optimized version of that:

import { html,render } from 'https://unpkg.com/htm/preact/standalone.mjs'

例子:

<!DOCTYPE html>

<html lang="en">

<title>htm Demo</title>

<script type="module">

import { html,Component,render } from 'https://unpkg.com/htm/preact/standalone.mjs';

class App extends Component {

addTodo() {

const { todos = [] } = this.state;

this.setState({ todos: todos.concat(`Item ${todos.length}`) });

}

render({ page },{ todos = [] }) {

return html`

<div class="app">

<${Header} name="ToDo's (${page})" />

<ul>

${todos.map(todo => html`

<li>${todo}</li>

`)}

</ul>

<button onClick=${() => this.addTodo()}>Add Todo</button>

<${Footer}>footer content here<//>

</div>

`;

}

}

const Header = ({ name }) => html`<h1>${name} List</h1>`

const Footer = props => html`<footer ...${props} />`

render(html`<${App} page="All" />`,document.body);

</script>

</html>

GitHub:https://github.com/developit/htm

网站描述:使用标准标记模板的 JSX 替代方案

htm官方网站

官方网站:

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

相关文章

jade,Jade 是一个高性能的模板引擎,以 JavaScript 的形式集...
curl.js,轻量级,快速,可扩展的模块加载
jspm-cli,基于SystemJS的Js包管理器
angular-cli,快速构建Angular2项目
lerna,一款多项目多模块的管理工具
duo.js,前端的下一代包管理器。