dvajs / dva-example-user-dashboard Goto Github PK
View Code? Open in Web Editor NEW👲 👬 👨👩👧 👨👩👦👦
👲 👬 👨👩👧 👨👩👦👦
Failed to start the server, since you have enabled dllPlugin, but have not run roadhog buildDll
before roadhog server
.
我的项目有五六十个页面,使用npm run build打包不成功,报内存溢出错误 ,使用npm run build --max-old-space-size=8192无效
这个例子中state connect的是Presentation Component不是Container component, 会对dva初学者造成困惑。
这个项目拉下来后,没有改动,运行 npm install,再运行npm run build,把dist文件夹拷贝到apache服务下后,浏览这个index.html,发现页面是空白的。
npm start 是可以看到demo效果的
package.json 的依赖:
"dva": "^1.4.0-beta.1",
"roadhog": "^0.6.0"
这两个依赖过老,尤其dva版本使用的API和新版很多不一致的地方,更新dva 2.1.0后项目没法跑起来,在dva使用上已经没有参考价值了,roadhog可以根据文档升级解决,请及时更新,谢谢。
你好,本人前端新手,这两天研究了下dva
,感觉非常棒,准备用来做公司的管理系统试一试。但是遇到了下面这个问题:
npm start
之后的调试都没有问题,但是npm run build
后,我理解的是打开index.html
文件应该显示跟npm start
时一样的页面,可是我这边一片空白,在Network里看3个文件也都在,不知道为什么?
node 7.0.0
roadhog 0.2.3
index.js:1871 Warning: [react-router] Location "...../dist/index.html" did not match any routes
按照documentation步驟走的,不知道跟enquire依賴有什麼衝突?
Creating` dll bundle...
Failed to compile.
Module not found: Error: Cannot resolve module 'nstore' in E:\_javascript\dva-example-user-dash
board\node_modules\enquire\examples\data-integration
如果想在新增用户的时候做一下验证,比如说验证用户是否存在,应该怎么做呢
Hi, I'm following this tutorial and I was wondering how can I change the default language to spanish?.
I've seen this documentation https://ant.design/components/locale-provider but it doesn't show where should I do the changes so it's not very helpful, maybe that section of the documentation could be more explicit.
Thanks in advance for your help
终端提示信息如下
G:\dva-example-user-dashboard-master>npm start
@ start G:\dva-example-user-dashboard-master
roadhog server
Failed to start the server, since you have enabled dllPlugin, but have not run roadhog buildDll
before roadhog server
.
@sorrycc ,请问下,我在你的demo里,router.js文件里 path:users的路径下新建了个childRoutes path:add,为什么页面不渲染这个路径的组件,却还是渲染users组件呢?
"disableCSSModules": true 已经改为true了,但是还是在components中的CSSModule无法加载,
请问怎么解决呢?
id过长会自定截取变为00
export default async function request(url, options) {
console.log('opotions:'+options);
const response = await fetch(url, options);
/console.log(response);/
checkStatus(response);
const data = await response.json();
const ret = {
data,
headers: {},
};
if (response.headers.get('x-total-count')) {
ret.headers['x-total-count'] = response.headers.get('x-total-count');
}
console.log("ret:"+ret);
return ret;
}
request.js里面的方法, 列表查询:const data = await response.json();这句获取的id如果超过16位,比如18位,后两位就会变成00(如:842996249664786432 -- >842996249664786400)
不知道啥情况??
错误如下:
这个例子,我感觉我是学不了.哈哈~
Failed to start the server, since you have enabled dllPlugin, but have not run roadhog buildDll
before roadhog server
.
点击进入 user 页面不能及时渲染,显示 无数据
执行build,indexPage和Users打包出的js文件中存在大量的 .ant-menu-... 等样式代码,请问如何把这些重复的代码提取到index.css中?
以前在webpack中是用ExtractTextPlugin提取,请问在dva roadhog中应该怎么配置?
[Fri Sep 15 2017 10:08:34 GMT+0800 (CST)] "GET /" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"
[Fri Sep 15 2017 10:08:34 GMT+0800 (CST)] "GET /roadhog.dll.js" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"
[Fri Sep 15 2017 10:08:34 GMT+0800 (CST)] "GET /index.js" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"
[Fri Sep 15 2017 10:08:34 GMT+0800 (CST)] "GET /roadhog.dll.js" Error (404): "Not found"
将build 之后的文件放在本地tomcat /antd目录下,
访问 http://localhost:8080/antd/ 页面空白
Network 中
http://localhost:8080/antd/roadhog.dll.js 404
请问:
如果要用本地字体文件,应该放在“public”还是“src/assets”目录下?
.roadhogrc:
{
"theme": {
"@icon-url": "'/assets/fonts/iconfont/iconfont'"
}
}
roadhog配置信息是这么写么?
跑npm start的时候没问题,但是打包后加载,页面是空白的,也没有报错。
自己试了一下,发现是路由按需加载的require里并没有执行,网上找了方法,说是ES6的写法 要加.default,但是我自己试了,没有效果。
npm run build 之后 Users 数据无法加载。
"proxy": { "/api": { "target": "http://jsonplaceholder.typicode.com/", "changeOrigin": true, "pathRewrite": { "^/api" : "" } } },
http://localhost:8080/api/users?_page=1&_limit=3
和 dva/React 相关的,假如下面场景:
有一个页面(Route Component),显示用户列表,然后有查看详情功能,点击列表项的“详情”按钮,就会出现一个弹层,弹层显示详情,详情是单独一个组件。
这样有两个文件:
UserList.jsx
UserDetail.jsx
假如UserList.jsx
放到routes
目录,那么UserDetail.jsx
放到哪里呢?这个文件只在这里使用,我会放在components
目录,但是有人问我“和UserList.jsx
放到一起不是更合理一些,因为功能相关。
build之后,开启http-server服务器,可访问,刷新后显示空白
想请教下运行npm run build后生成的js文件如何使用?
我在静态文件index.html中添加以下script的引用:
`
<script src="index.js"></script> <script src="2.2.js"></script> <script src="1.1.js"></script>`
其中2.2.js、1.1.js、index.js是build后生成的js。
使用浏览器查看index.html(未通过server),页面未显示预期的效果。以上问题出 在哪里,我还需要做哪些工作来正确使用build后的文件,多谢!
在请求的时候加上headers,这个贴出patch的代码,本人测试有效。
export function patch(id, values) {
return request(/api/users/${id}
, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
// 'Access-Token': sessionStorage.getItem('access_token') || ''
},
body: JSON.stringify(values),
});
侧边栏刷新后的选中菜单消失,查看代码后发现是components/menus/index中handleClickNavMenu函数没有传进来,请看下
dva-example-user-dashboard/.roadhogrc
Lines 20 to 23 in d6da33b
I want to modify special style, such as row padding of module Table body in .css or .scss. Do I need to import something?
My code:
.ant-table-tbody > tr > td {
padding: 13px 8px !important;
}
刚开始遇到编译失败的问题
手动调整roadhog为 "roadhog": "^1.2.2"
页面终于正常运行
但是 users页面依然无效,报错信息如下
ReferenceError: regeneratorRuntime is not defined
Stack trace:
request<@webpack-internal:///552:15:7
@webpack-internal:///552:14:15
[552]@http://localhost:8000/2.async.js:55:1
webpack_require@http://localhost:8000/index.js:708:12
fn@http://localhost:8000/index.js:113:20
@webpack-internal:///551:11:16
[551]@http://localhost:8000/2.async.js:47:1
webpack_require@http://localhost:8000/index.js:708:12
fn@http://localhost:8000/index.js:113:20
@webpack-internal:///414:13:14
[414]@http://localhost:8000/2.async.js:7:1
webpack_require@http://localhost:8000/index.js:708:12
fn@http://localhost:8000/index.js:113:20
const routes = [
{
path: '/',
component: App,
breadcrumbName: '首页',
getIndexRoute(nextState, cb) {
require.ensure([], require => {
cb(null, {component: require('./routes/indexPage')})
}, 'index')
},
childRoutes: [
{
path: '/user',
breadcrumbName: '用户列表',
getComponents(nextState, cb) {
require.ensure([], require => {
registerModel(app, require('./models/user'))
cb(null, require('./routes/user/list/'))
}, 'user')
},
childRoutes:[
{
path: ':id',
breadcrumbName: '用户:id',
getComponents(nextState, cb) {
require.ensure([], require => {
//registerModel(app, require('./models/user'))
cb(null, require('./routes/user/detail/'))
}, 'user')
},
},
]
}, {
path: '*',
breadcrumbName: 'error',
getComponent(nextState, cb) {
require.ensure([], require => {
cb(null, require('./routes/error/'))
}, 'error')
}
}
]
}
];
这时候 :id这个路由的component 渲染不出来,依然是 list
import request from '../utils/request';
// request(url, options)
import { PAGE_SIZE } from '../constants';
// 分页 size 3
// http://localhost:8000/sockjs-node/info?t=1499839053437
// GET
// ??? where are you get the mock/fake datas ???
export function fetch({ page }) {
// http://localhost:8000/users?page=2
// http://localhost:8000/api/users?_page=2&_limit=3
// GET
return request(`/api/users?_page=${page}&_limit=${PAGE_SIZE}`);
}
// http://localhost:8000/api/users/4
// DELETE
export function remove(id) {
return request(`/api/users/${id}`, {
method: 'DELETE'
});
}
// http://localhost:8000/api/users/4
// PATCH
export function patch(id, values) {
return request(`/api/users/${id}`, {
method: 'PATCH',
body: JSON.stringify(values)
});
}
// http://localhost:8000/api/users/4
// POST
export function create(values) {
return request('/api/users', {
method: 'POST',
body: JSON.stringify(values)
});
}
11:40 Uncaught Error: A may have only one child element
at invariant (11:40)
at Router.componentWillMount (95:72)
at eval (412:347)
at measureLifeCyclePerf (412:75)
at ReactCompositeComponentWrapper.performInitialMount (412:346)
at ReactCompositeComponentWrapper.mountComponent (412:257)
at Object.mountComponent (50:45)
at ReactCompositeComponentWrapper.performInitialMount (412:370)
at ReactCompositeComponentWrapper.mountComponent (412:257)
at Object.mountComponent (50:45)
使用本地json-server时,编辑用户和创建用户操作不生效;
需要在访问request方法时,初始化options参数的headers
文件:services/user.js
export function patch(id, values) {
return request(`/api/users/${id}`, {
method: 'PATCH',
body: JSON.stringify(values),
headers: {
"Content-Type": "application/json"
},
});
}
export function create(values) {
return request('/api/users', {
method: 'POST',
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(values),
});
}
使用线上json-server时,编辑用户和创建用户操作始终不生效;
手动改这里是可以看到数据改变的
*fetch({ payload: { page = 1 } }, { call, put }) {
const { data, headers } = yield call(usersService.fetch, { page });
yield put({
type: 'save',
payload: {
data,
total: parseInt(headers['x-total-count'], 10),
page: parseInt(page, 10),
},
});
},
比如,删除的时候,数据库已经删除完成,但是table中还是有那条数据
Failed to start the server, since you have enabled dllPlugin, but have not run
roadhog buildDllbefore
roadhog server.
点击导航栏,地址栏变化,但是界面没有变化
Cannot read property 'call' of undefined
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.