Giter Site home page Giter Site logo

Comments (8)

coderz-w avatar coderz-w commented on June 18, 2024

image

from ant-design.

zombieJ avatar zombieJ commented on June 18, 2024

HOC 传入,status。自定义元素的属性不一定也叫 status

const MyInput = ({ checkStatus, className, ...props }) => {
  return <input className={classNames(className, `my-status-${status}`)} {...props} />
};

from ant-design.

zombieJ avatar zombieJ commented on June 18, 2024

自行封装 AutoComplete 后,你可以同时把 status 传给需要的地方:

// 参考你的 PR,封装业务组件。而不是写死在 antd 中
const MyAutoComplete = ({ status, ...props }) => (
  <AutoComplete {...props} status={status}>
    {cloneElement(...)}
  </AutoComplete>
);

from ant-design.

AmberSanyu avatar AmberSanyu commented on June 18, 2024

自行封装 AutoComplete 后,你可以同时把 status 传给需要的地方:

// 参考你的 PR,封装业务组件。而不是写死在 antd 中
const MyAutoComplete = ({ status, ...props }) => (
  <AutoComplete {...props} status={status}>
    {cloneElement(...)}
  </AutoComplete>
);

现在明显是文档和实际使用对不上呀,不解决吗?靠使用时自己重新封装来规避吗? @zombieJ 这样直接就关了?
image

from ant-design.

AmberSanyu avatar AmberSanyu commented on June 18, 2024

image

我找了好几个人试能打开没问题,

from ant-design.

AmberSanyu avatar AmberSanyu commented on June 18, 2024

@afc163 您好,这个官方会解决吗

from ant-design.

afc163 avatar afc163 commented on June 18, 2024

我看 @zombieJ 已经给出解决方案了,而且确实有道理:#48871 (comment)

自定义组件也不一定都会换成 antd 的,也可以换成原生 input 组件,你无法期待原生 input 也有 status 属性。

如果使用自定义组件换掉内建组件了,一些相关属性确实可能会失效,需要自己补上。不只是 status,variant 也会丢失。

from ant-design.

AmberSanyu avatar AmberSanyu commented on June 18, 2024

我看 @zombieJ 已经给出解决方案了,而且确实有道理:#48871 (comment)

自定义组件也不一定都会换成 antd 的,也可以换成原生 input 组件,你无法期待原生 input 也有 status 属性。

如果使用自定义组件换掉内建组件了,一些相关属性确实可能会失效,需要自己补上。不只是 status,variant 也会丢失。

首先,感谢上面老师给的解决方案
然后我的问题是: @afc163
目前官方文档的描述来看,代码存在问题,并不符合预期。
为什么只是仅仅在这里给我一个解决方案,然后就关闭了issue,
难道不应该去修复这个问题,或者确定不提供这个使用方式,需要自己重新封装就改官方说明文档呀。

from ant-design.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.