Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

考虑导出组件的 props 么, 方便二开使用 #3135

Closed
1 task done
Zhang-Wei-666 opened this issue May 14, 2024 · 8 comments
Closed
1 task done

考虑导出组件的 props 么, 方便二开使用 #3135

Zhang-Wei-666 opened this issue May 14, 2024 · 8 comments

Comments

@Zhang-Wei-666
Copy link

Zhang-Wei-666 commented May 14, 2024

基本信息

二开时可以直接继承导出的 props 类型及类型定义

现有案例

arco-design

naive-ui

element-plus

预期解决问题

和 arco-design 一致

@lin-97
Copy link

lin-97 commented Jun 18, 2024

你是不会用 v-bind 还有
defineOptions({ inheritAttrs: false })
const attrs = useAttrs()
进行二开吗?

@Zhang-Wei-666
Copy link
Author

你是不会用 v-bind 还有 defineOptions({ inheritAttrs: false }) const attrs = useAttrs() 进行二开吗?

image

要的是类型定义啊 😑
二开封装的组件, 继承类型定义, 组件就有代码提示了啊

@Zhang-Wei-666
Copy link
Author

算了, 不指望了 🤷‍♂️

@lin-97
Copy link

lin-97 commented Jun 27, 2024

你是没用过这种吗
import type * as A from '@arco-design/web-vue'
A.InputInstance['$props']
A.FormItemInstance['$props']

@Zhang-Wei-666
Copy link
Author

你是没用过这种吗 import type * as A from '@arco-design/web-vue' A.InputInstance['$props'] A.FormItemInstance['$props']

@lin-97

我现在是这样用的 https://mixte.moomfe.com/mixte/snippets/acro-dynamic-form#ResetButtonOptions

问题是这样使用因为类型被包装过, 但是如果直接 extends 去继承原有组件的 props, 对于 Vue 来说太复杂, 打包时会报错

Clip_2024-06-27_19-22-34

只能按照提示强行忽略, 最终生成的代码中, 也不会包含原有组件的 props 定义

Clip_2024-06-27_19-38-53

不是不能用, 就是希望能更好

@lin-97
Copy link

lin-97 commented Jun 27, 2024

个人认为,非必要尽量不要过度封装组件,经历过大大小小项目总结出来,过渡封装只会自食其果,后面慢慢变成屎山,过渡封装,新人看不懂是懒得用的,还不如跟我主页项目一样,能不封装就尽量不封装

@lin-97
Copy link

lin-97 commented Jun 28, 2024

@Zhang-Wei-666
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants