dva如何去掉hash
程序员文章站
2022-06-06 23:38:39
...
解决方案
import React from 'react';
import dva from 'dva';
import App from './router';
import createLoading from '@/common/utils/create-loading';
import {createBrowserHistory as createHistory} from 'history'; // 关键在这里
import { default as Login } from './models/login';
import { default as myHome } from './models/myHome';
import 'antd/dist/antd.css';
import './index.less';
// 1. Initialize
const app = dva({
history: createHistory(), // 关键在这里
});
// 2. Plugins
app.use(createLoading());
// 3. Model
app.model(Login);
app.model(myHome);
// 4. Router
// app.router(require('./router').default);
app.router(props => <App {...props} />);
// 5. Start
app.start('#root');
export default app._store;
解决的关键在入口文件中的注释上,引入createBrowserHistory