0.0.29 • Published 4 years ago

@avairain/j2r v0.0.29

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

开始

安装

npm i @avairain/j2r

配置文件

j2r.config.json

{
  "file": "input.json", // 入口
  "template": "./template/index.html", // 模板回填 page.title page.cssLink
  "root": "./dist" // 导出
}

构建

j2rbuild

监听入口文件

j2r

修改配置文件

j2r --config=your.config.json --root=dist

input.json

{
  "route": { // 路由 基于 react-router-dom
    "type": "BrowserRouter", // react-router-dom HashRouter BrowserRouter,
    "children": [ // 子节点(路由)
      {
        "type": "Route",
        "props": {
          "path": "/" // 路由
        },
        "children": [
          {
            "type": "View.B" // view.B 组件
          }
        ]
      },
      {
        "type": "span",
        "children": ["span"]
      }
    ]
  },
  "view": {
    "B": {
      "type": "div",
      "usingHooks": [ // 使用的hooks
        {
          "name": "useState, useEffect",
          "package": "react"
        },
        {
          "name": "useBoolean",
          "package": "ahooks" // 第三方的包需要手动安装
        }
      ],
      "props": {
        "onClick": "function: (e) => console.log(e)",
        "style": {
          "color": "red"
        }
      },
      "children": [
        "c",
        "{props.children}",
        {
          "type": "AAAA.B" // import OtherLib from 'other-lib' AAA => a-a-a
        }
      ] // <div onClick={(e) => console.log(e)}>{props.children}</div>
    }
  },
   "page": {
    "title": "页面标题",
    "cssLink": ["css链接"],
    "appRoot": "根节点",
    "body": [
      {
        "type": "元素类型",
        "props": { // 元素属性
          "id": "root"
        }
      }
    ]
  }
}
0.0.29

4 years ago

0.0.20

4 years ago

0.0.21

4 years ago

0.0.22

4 years ago

0.0.23

4 years ago

0.0.24

4 years ago

0.0.25

4 years ago

0.0.15

4 years ago

0.0.16

4 years ago

0.0.17

4 years ago

0.0.18

4 years ago

0.0.19

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.26

4 years ago

0.0.9

4 years ago

0.0.27

4 years ago

0.0.28

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago