簡單配置umiJS學習筆記

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


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

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"
  }
};
相關文章
相關標籤/搜索