yarn add @ant-design/compatible@v5-compatible-v4
Helps you to compatible different components between v4 and v5.
-- import { Button, Select, Dropdown } from 'antd';
++ import { Button, Select, Dropdown } from '@ant-design/compatible';
Home Page: https://compatible.now.sh
License: MIT License
设置Form
组件为inline
模式时,属性labelCol
与wrapperCol
失效
inline
时将ant-legacy-form-item
设置为了inline-block
,导致ant-col
的flex
属性失效
flex: 1 1 0%
5.Input 表单项宽度丢失
表单正常显示
Input宽度丢失
Environment | Info |
---|---|
antd | 4.12.2 |
React | 16.8 |
System | windows |
Browser | chrome 88 |
devScripts.js:6523 Warning: [antd-compatible: Form] The legacy component has been deprecated, and ant design 4.0 now released! Please follow https://ant.design/components/form to upgrade.
目前工作用到了非常多的 Form v3,我們沒有人力將 Form重構到 v4。預計永遠不會重構,所以希望有辦法關掉這個警告。
@ant-design/compatible
导入antd
导入import React from "react";
import ReactDOM from "react-dom";
import { Form } from "@ant-design/compatible";
import { Button, Radio } from "antd";
import "@ant-design/compatible/assets/index.css";
class MyForm extends React.Component {
render() {
const { form } = this.props;
return (
<Form
onSubmit={e => {
e.preventDefault();
form.validateFieldsAndScroll((err, values) => {
if (!err) {
console.log("values", values);
}
});
}}
>
<Form.Item>
{form.getFieldDecorator("radio1", { initialValue: "1" })(
<Radio.Group
options={[
{ label: "radio1 item1", value: "a" },
{ label: "radio1 item2", value: "b" }
]}
/>
)}
</Form.Item>
<Form.Item>
{form.getFieldDecorator("radio2", { initialValue: "1" })(
<Radio.Group>
<Radio value="1">radio2 item1</Radio>
<Radio value="2">radio2 item2</Radio>
</Radio.Group>
)}
</Form.Item>
<Button htmlType="submit">Submit</Button>
</Form>
);
}
}
const AForm = Form.create()(MyForm);
ReactDOM.render(<AForm />, document.getElementById("container"));
radio1能正确获取到值
Environment | Info |
---|---|
antd | 4.5.1 |
React | 16.13.1 |
System | window 10 |
Browser | chrome 84 |
In v1.0.3 was added assets/index.less file which have this content:
@import '../src/form/style/index.less';
@import '../src/mention/style/index.less';
But files on these paths do not exist. Therefore a compilation error occurs.
我只想用兼容包中的form,然后fork了一份代码,在编译的过程中提示:
NameError: variable @input-affix-width is undefined in /Users/changzhn/projects/react-group/compatible/src/form/style/index.less on line 145, column 55:
请问这个该如何解决?
node: v12.16.1
npm: 6.13.4
提示用户你正在使用 Legacy 并引导升级。
@MadCcc do i have to config less loader fot this
import {Comment} from '@ant-design/compatible'
error - ./node_modules/@ant-design/compatible/es/comment/style/index.less
Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> @import '../../style/default';
| // @import '../../style/mixins/index';
1.1.2版本的@ant-design/compatible中的package.json里写有peer dependencies, antd为3.x。我理解这个是v3升级到v4的兼容包,那么宿主环境中装的antd版本应该是v4的,这里为什么要这么限制呢?同时因为我的项目必须升级至react17以上,所以也不可能有antd3共存在项目中。
@ant-design/compatible/assets/index.css
报错node_modules
中未发现该文件 "@ant-design/compatible": "^0.0.1-alpha.9"
https://stackblitz.com/edit/react-xzpoae
在第一个输入框输入任意字符,然后清空,input会出现红色边框,从4.0.3引入的form组件则没有
获取焦点的时候,错误提示红色的框应该出现在最外层
Environment | Info |
---|---|
antd | 4.0.3 |
React | 16.13.0 |
System | windows7 |
Browser | chrome80.0.3987.132 |
Originally posted by @LJJCherry in ant-design/ant-design#21907 (comment)
Row组件的基础样式由display: block;
变更成display: flex;
造成基本上每个页面都要修改,工作量实在是太大了。
@ant-design/compatible 1.1.0
antd 4.18.9
只有一个Form表单,表单内根据数组循环生成表单项,当表单项达到一定数量后,输入框输入非常卡顿。请教一下大佬们有什么优化方式吗?
复现步骤
1.在name文本框输入任意内容触发onFieldsChange
2.查看控制台输出接口allValues中的id字段的initialValue 中初始值不在里面
复现demo:https://codesandbox.io/s/ant-design-compatible-onfieldschange-initialvalue-v3gg2i
期望:可以在onFieldsChange中拿到初始值
import { Icon as LegacyIcon } from '@ant-design/compatible';
JSX 元素类型“LegacyIcon”不具有任何构造签名或调用签名。
Hi,
issue here after compiling:
Compiled with problems:X ERROR in ./node_modules/@ant-design/compatible/es/form/index.js 2:0-107 export 'FormProps' (reexported as 'FormProps') was not found in './Form' (possible exports: default) ERROR in ./node_modules/@ant-design/compatible/es/form/index.js 2:0-107 export 'FormComponentProps' (reexported as 'FormComponentProps') was not found in './Form' (possible exports: default) ERROR in ./node_modules/@ant-design/compatible/es/form/index.js 2:0-107 export 'FormCreateOption' (reexported as 'FormCreateOption') was not found in './Form' (possible exports: default) ERROR in ./node_modules/@ant-design/compatible/es/form/index.js 2:0-107 export 'ValidateCallback' (reexported as 'ValidateCallback') was not found in './Form' (possible exports: default) ERROR in ./node_modules/@ant-design/compatible/es/form/index.js 2:0-107 export 'ValidationRule' (reexported as 'ValidationRule') was not found in './Form' (possible exports: default) ERROR in ./node_modules/@ant-design/compatible/es/form/index.js 3:0-43 export 'FormItemProps' (reexported as 'FormItemProps') was not found in './FormItem' (possible exports: default)
I've used the last package, 5.1.0
I don't know what is happened. Seems all ok in my project, only this one fails. Can somebody check in this export?
Thanks guys!
Is there a way to keep the theme customizations done by overriding the less-variables as described here https://ant.design/docs/react/customize-theme#Ant-Design-Less-variables when using @ant-design/compatible
We used them quite a bit for version 3, and now that we have migrated to version 4 and use the @ant-design/compatible the overrides don't work anymore.
There's a new vulnerability with the async-validator version <4.0.4. Need to upgrade to latest
https://security.snyk.io/vuln/SNYK-JS-ASYNCVALIDATOR-2311201
umi3 引用@ant-design/compatible/assets/index.less报错,无法识别@import (reference) 'antd/dist/antd.less'
react 16.13.1
@types/react 16.9.34
升级迁移 兼容V3时 Form & FormItem报错
// tsconfig
{
"compilerOptions": {
"baseUrl": "src",
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"experimentalDecorators": true,
"noImplicitThis": false
},
"include": [
"src"
],
"extends": "./paths.json"
}
<LegacyForm.Item label={index === 0 ? '部门' : ''} >
{form.getFieldDecorator(`departmentIds[_${item}]`, {
rules: required === false ? [] : [{ required: true, message: '请选择部门' }],
initialValue: index < (departmentList || []).length ? initDepartmentObj[item] : undefined
})(
<Cascader
options={getOptions(data)}
placeholder="请选择"
className={styles['multiple-select-cascader']}
displayRender={(label:any) => label.join(' - ')}
getPopupContainer={(triggerNode:{parentNode:React.ReactNode}) => triggerNode.parentNode}
{...rst}
/>
)}
</LegacyForm.Item>
@ant-design/compatible 1.1.0
antd 4.19.1
umi子应用按照如下方式引入
import '@ant-design/compatible/assets/index.less';
import 'antd/dist/antd.less';
出现以下报错,但是主应用 node_modules
中有 node_modules/antd/dist/antd.less
error in /project/node_modules/@ant-design/compatible/assets/index.less
Module build failed (from /project/node_modules/@umijs/bundler-webpack/lib/webpack/plugins/mini-css-extract-plugin/src/loader.js):
ModuleBuildError: Module build failed (from /project/node_modules/@umijs/deps/compiled/less-loader/cjs.js):
@import (reference) 'antd/dist/antd.less';
^
Can't resolve './antd/dist/antd.less' in '/project/node_modules/@ant-design/compatible/lib/form/style'
This style is changing our radio
and checkbox
inputs globally in our code (line 229).
compatible/src/form/style/index.less
Line 145 in 2847470
The same style in ant-design/ant-design is using a prefix to modify its children.
import { DatePicker, ConfigProvider } from 'antd';
import 'moment/locale/zh-cn';
import locale from 'antd/lib/locale/zh_CN';
import moment from 'moment';
moment.locale('zh-cn', {
week: {
dow: 3
}
});
<ConfigProvider locale={locale}>
<DatePicker />
</ConfigProvider>
做全局的配置没有任何作用
How do I customize the colorBgContainer style for the compatible/Comment
component? I've tried many different guesses in the ConfigProvider theme property, including
components: {
Comment: {
colorBgContainer: 'transparent',
},
}
as well as
components: {
compatible: {
Comment: {
colorBgContainer: 'transparent',
},
},
}
and I can't get it to take. Documentation for theming compatible components is completely absent. Any help is appreciated.
V3到V4升级之后,在全局都没有用@ant-design/icons,请问怎样把这个包卸载掉
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.