$ cd eleme-demo
$ npm run dev:ui
umijs / umi-examples Goto Github PK
View Code? Open in Web Editor NEWexamples for umi.js
examples for umi.js
运行ts 目录下的项目报错
This dependency was not found:
To install it, you can run: npm install --save components/A
1、package.json里没有启动脚本
2、把别的项目里的脚本加进去后,能启动,但是不认less文件,界面样式混乱
重现步骤:
"baseUrl":"src",
"paths": {
"components": ["components"]
},
Cannot find module '../components/count' from 'a.test.ts'
尝试将 baseUrl 分别替换以下路径,仍然会进行报错
"baseUrl":"./src/",
"paths": {
"components": ["components"]
}
"baseUrl":".",
"paths": {
"components": ["src/components"]
}
这是配置的问题还是 umi-test 无法读取 ts 的配置?
在windows平台下执行npm run dev会报错,看了下.umi下的umi.js文件:
生成的路径不能识别,应该是node中处理windows和linux的路径分隔符不同导致的。
暂时先将umi-plugin-entry.js插件里面的
api.modifyEntryRender(memo => { memo =
const rootContainer = window.g_plugins.apply('rootContainer', {
initialValue: React.createElement(require('${join(__dirname, "./redux/index")}').default,
null,
React.createElement(require('./router').default),),
});替换成了相对路径:
api.modifyEntryRender(memo => {
memo = const rootContainer = window.g_plugins.apply('rootContainer', { initialValue: React.createElement(require("../../redux/index").default, null, React.createElement(require('./router').default),), });
const page: FC<PageProps> = function(props) {
const handleAdd = () => {
props.dispatch(add());
};
const handleMinus = () => {
props.dispatch(minus());
};
console.log(props.xxx) // 这里props里面并没有xxx属性,ts编译却通过了
return (
<Fragment>
</Fragment>
);
};
请问这里是ts哪里没有配置好吗?
预期是希望类型不对,能够编译不通过
cd with-dva-and-immer
npm i && umi dev
Error: Cannot find module '../lib/scripts/dev'
react官网有个例子,源码如下:
function tick() {
const element = (
<div>
<h1>Hello, world!</h1>
<h2>It is {new Date().toLocaleTimeString()}.</h2>
</div>
);
ReactDOM.render(element, document.getElementById('root'));
}
setInterval(tick, 1000);
我使用UmiJs构建的项目,选择的模板是ant-design-pro。页面 = 路由 + layout + 自定义组件。(理解地没错吧)。
请问,在children组件里,怎么调用setInterval?在layout里调用?
First of all, thanks for all your work. umi is amazing!
You think we can an example of umi2 with mobx and mobx-state-tree ?
Thanks again!
先收录参考,考虑需要不需要提供一个关于动画比较完整的例子
https://web-animations.github.io/web-animations-demos/#phone/
https://github.com/react-component/animate
还有一个问题,如果只是在组件自己的state,是不是还要经过model.reducers来修改还是说依然建议使用this.setState来修改
目录:umi-examples/with-redux/
根据文档的Getting Started依次运行报错
如题
我注意到在这个例子中,在dva的model里使用了dva/router的reduxRouter而不是umi/router的router,请问有什么区别么?我尝试在model中使用umi/router,会提示TypeError: Cannot read property 'type' of undefined 也就是调用dispatch时不能识别type,是这个意思么?
你好,感谢你提供这样一个例子。但是我在实际尝试使用的时候发现app.js里面的钩子都是在页面启动的时候就调用的,而我们的的情况是需要用户先登录,登陆完成后再通过用户凭证去后台请求用户的路由表(估计很多用户需要运行时修改路由表的用户都会是这种情况)。这时这个例子就不是很适用了,请问一下这种情况下应该怎样做呢?
在配置路由中可以在 path
里使用正则实现,那约定式路由如何实现呢?
配置路由的动态路由匹配模式:issues2272
我看了案例中页面里是这样获取的:
export default ({ match }) =>
<div>
<h1>/users/{match.params.id}</h1>
</div>
但是如果页面是以下这样:
class Page extends React.Components {
这里该如何获取 id?
}
export default Page;
报错信息如下:
.sourceMap is an alias for .sourceMaps, cannot use both
error E:\umi-examples\with-dva\node_modules\electron: Command failed.
Exit code: 1
Command: node install.js
Arguments:
Directory: E:\umi-examples\with-dva\node_modules\electron
Output:
Downloading electron-v1.8.6-win32-x64.zip
Error: connect ETIMEDOUT 54.231.120.163:443
E:\umi-examples\with-dva\node_modules\electron\install.js:47
throw err
^
Error: connect ETIMEDOUT 54.231.120.163:443
at Object._errnoException (util.js:1022:11)
Throws error saying ROUTES_MODIFER cannot be destructed because it's null/undefined.
I solved this by changing:
to:
const { service: { paths }, placeholder: { ROUTES_MODIFIER } = {} } = api;
If there is a better solution to this please advise. Otherwise will gladly open a pull request
我希望umi可以对null值做严格的测试(不要给对象赋值null!编译的时候就报错)。demo如下:
it("test null check", () => {
let name:string = null
expect(name).toBe(null)
})
umi test
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.