当前位置: 首页 > 工具软件 > HyperApp > 使用案例 >

[Hyperapp] Render Text with JSX in Hyperapp

郦楷
2023-12-01

Hyperapp is an ultra lightweight (1kb), minimal, functional, JavaScript library for building UIs. It comes with a VDOM engine and state management without any dependencies.

In this lesson, we learn how to use JSX with Hyperapp. By installing a Babel plugin, we can instruct it to transpile JSX to Hyperapp's h method for a better developer experience.

 

install:

npm i -D babel-plugin-transform-react-jsx

 

.babelrc file:

{
  "plugins": [
    ["transform-react-jsx", { "pragma": "h" }]
  ],
  "presets": [
    "env"
  ]
}

 

import { h, app } from 'hyperapp'

const view = () => (
  <div>
    <h1>Hyperapp is sweet!</h1>
  </div>
)

const main = app({}, {}, view, document.body)

 

转载于:https://www.cnblogs.com/Answer1215/p/8428059.html

 类似资料:

相关阅读

相关文章

相关问答