W3Cschool
恭喜您成為首批注冊(cè)用戶(hù)
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
支持?jǐn)U展類(lèi)型: ml, re
ReasonML在BuckleScript 的幫助下將 OCaml 編譯為 JavaScript。通過(guò)安裝依賴(lài)和創(chuàng)建bsconfig.json文件使用 ReasonML。
$ yarn add bs-platform --dev
// bsconfig.json
// from https://github.com/BuckleScript/bucklescript/blob/master/jscomp/bsb/templates/basic-reason/bsconfig.json
{
"name": "whatever",
"sources": {
"dir": "src",
"subdirs": true
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": [],
"warnings": {
"error": "+101"
},
"namespace": true,
"refmt": 3
}
<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<script src="./src/index.re"></script>
</body>
</html>
/* src/index.re */
print_endline("Hello World");
ReasonReact 通過(guò) ReasonML 構(gòu)建 React。當(dāng)然也能在 Parcel 中使用:
$ yarn add react react-dom reason-react
// bsconfig.json
{
"name": "whatever",
+ "reason": {
+ "react-jsx": 3
+ },
"sources": {
"dir": "src",
"subdirs": true
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": [
+ "reason-react"
],
"warnings": {
"error": "+101"
},
"namespace": true,
"refmt": 3
}
<!-- index.html -->
<html>
<body>
+ <div id="app"></div>
<script src="./src/index.re"></script>
</body>
</html>
/* src/Greeting.re */
[@react.component]
let make = (~name) => {
<div> {React.string("Hello! " ++ name)} </div>;
};
/* src/index.re */
ReactDOMRe.renderToElementWithId(<Greeting name="Parcel" />, "app");
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話(huà):173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: