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" />
博客园作者:herry菌朋友,看到这里,关注作者的公众号吧,不漏掉更新哦