Skip to content

Amis โ€‹

ไธ€ไธชไฝŽไปฃ็ ๅ‰็ซฏๆก†ๆžถ๏ผŒๅฎƒไฝฟ็”จ JSON ้…็ฝฎๆฅ็”Ÿๆˆ้กต้ข๏ผŒๅฏไปฅๅ‡ๅฐ‘้กต้ขๅผ€ๅ‘ๅทฅไฝœ้‡๏ผŒๆžๅคงๆๅ‡ๆ•ˆ็އใ€‚

https://aisuda.bce.baidu.com/amis/zh-CN/docs/index

install โ€‹

bash
npm install amis

usage โ€‹

  • sdk ๅฝขๅผ

    npm i amis ๆฅไธ‹่ฝฝ๏ผŒๅœจ node_modules\amis\sdk ็›ฎๅฝ•้‡Œๅฐฑ่ƒฝๆ‰พๅˆฐใ€‚

html
<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="UTF-8" />
    <title>Amis ็คบไพ‹</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1"
    />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <link rel="stylesheet" href="https://unpkg.com/amis@latest/sdk/sdk.css" />
    <link
      rel="stylesheet"
      href="https://unpkg.com/amis@latest/sdk/helper.css"
    />
    <link
      rel="stylesheet"
      href="https://unpkg.com/amis@latest/sdk/iconfont.css"
    />
    <style>
      html,
      body,
      .app-wrapper {
        position: relative;
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <div id="root" class="app-wrapper"></div>
    <script src="https://unpkg.com/amis@latest/sdk/sdk.js"></script>
    <script src="amis.js"></script>
  </body>
</html>
js
(function () {
  let amis = amisRequire("amis/embed");
  let amisScoped = amis.embed("#root", {
    type: "page",
    title: "Amis ็คบไพ‹้กต้ข",
    body: [
      {
        type: "form",
        title: "็”จๆˆทไฟกๆฏ่กจๅ•",
        api: "/api/mock2/form/saveForm",
        body: [
          {
            type: "input-text",
            name: "name",
            label: "ๅง“ๅ",
          },
          {
            type: "input-email",
            name: "email",
            label: "้‚ฎ็ฎฑ",
          },
          {
            type: "input-number",
            name: "age",
            label: "ๅนด้พ„",
          },
          {
            type: "submit",
            label: "ๆไบค",
          },
        ],
      },
      {
        type: "crud",
        title: "็”จๆˆทๅˆ—่กจ",
        api: "/api/mock2/sample",
        columns: [
          {
            name: "id",
            label: "ID",
          },
          {
            name: "engine",
            label: "ๅผ•ๆ“Ž",
          },
          {
            name: "browser",
            label: "ๆต่งˆๅ™จ",
          },
          {
            name: "platform",
            label: "ๅนณๅฐ",
          },
          {
            name: "version",
            label: "็‰ˆๆœฌ",
          },
          {
            name: "grade",
            label: "็ญ‰็บง",
          },
        ],
      },
    ],
  });
})();

Released under the MIT License.