umijs 配置的一些用法和解釋 記錄


.umirc中配置和解釋:

 

設置請求代理:可以將當前訪問域名的請求轉發到指定域名下。用於跨域代理開發,開發完后放入指定服務器中。

//請求代理
  proxy: {
    '/api': {
      target: 'http://localhost:3000',
      changeOrigin: true,
      pathRewrite: {
        '^/api/': '/api/',
      },
    },
  },

打包和運行到指定目錄

base和publicPath一般一樣,指向css和js文件路徑,outoutPath是打包的文件放在哪個目錄中

//運行到某個目錄中
  base: '/timeaxis_web/',
  publicPath: '/timeaxis_web/',
  outputPath: '/timeaxis_web/',

配置為hash路由

  history: {
    type: 'hash',
  },

靜態路由,可以打包出history路由的頁面配置

exportStatic: {}, //靜態路由

用於配置路由,如果不寫就是自動路由,寫了之后自動路由無效了

  routes: [
    {
      path: '/preview',
      component: '../pages/preview',
    },
  ],

適配ie11

  targets: {
    ie: 11,
  },

開啟dva、antd等功能

  antd: {},
  dva: {
    hmr: true,
  },
  locale: {
    default: 'zh-CN',
    antd: true,
    baseNavigator: true,
  },

 

重定向到某個頁面 重定向到/home

import { Redirect } from 'umi';

<Redirect to="/home" />

 


免責聲明!

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



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