簡單配置umiJS學習筆記


最近跟着Antd-Pro官方教程學習umi,這里給大家推薦一下這個教程,特別適合初學者學習,教程涉及了AntD,AntD-Pro,umiJS,dvaJS等框架知識。


學習過程中跟着教程做了個Demo,下面貼出主要代碼

export default {
  // 用來表示項目文件夾(page,model等)是否為單數,默認為復數
  singular: true,
  // 選擇插件,這里是一個數組,一個插件是一個項,當項需要有別的參數的時候,這個項為一個數組,且這個數組第二個項是參數。
  plugins: [
    [
      // 開啟umi集成的antd和dva,注意umi-plugin-react需要單獨用npm i --save umi-plugin-react下載
      "umi-plugin-react",
      {
        antd: true,
        dva: true
        //
      }
    ]
  ],
  // 這里配置路由信息,需要注意這里是一個數組
  routes: [
    {
      path: "/",
      component: "../layout",
      routes: [
        {
          path: "/",
          component: "Helloworld"
        },
        {
          path: "helloworld",
          component: "Helloworld"
        },
        {
          path: "puzzlecards",
          component: "./puzzlecards"
        },
        {
          path: "list",
          component: "./list"
        },
        {
          path: "/dashboard",
          routes: [
            {
              path: "/dashboard/analysis",
              component: "Dashboard/Analysis"
            },
            {
              path: "/dashboard/monitor",
              component: "Dashboard/Monitor"
            },
            {
              path: "/dashboard/workplace",
              component: "Dashboard/Workplace"
            }
          ]
        }
      ]
    }
  ],
  // 這里配置代理,下面的意思是當api請求有/dev時會自動設置到目標鏈接,主要用於解決跨域問題。
  proxy: {
    "/dev": {
      target: "https://08ad1pao69.execute-api.us-east-1.amazonaws.com",
      changeOrigin: true
    }
  },
  // 在這里設置antd的主題相關配置,想要知道 antd 都定義了哪些變量,可以參考這里https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less
  theme: {
    "@primary-color": "#30b767"
  }
};


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM