.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" />