Skip to content
New issue

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

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

Already on GitHub? # to your account

refactor: defineProps改为Vue3.5解构语法 #799

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

liect
Copy link
Contributor

@liect liect commented Dec 17, 2024

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

💡 需求背景和解决方案

📝 更新日志

  • refactor: defineProps改为Vue3.5解构语法

  • 本条 PR 不需要纳入 Changelog

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

@liect liect changed the title refactor: defineProps改为Vue3.5解构语法 [WIP]refactor: defineProps改为Vue3.5解构语法 Dec 17, 2024
@liect
Copy link
Contributor Author

liect commented Dec 17, 2024

@timi137137 类似于这种情况中的默认值定义,需要改成解构的样式吗?
image

defineProps全改成通过ts的类型定义怎么样?

@timi137137
Copy link
Collaborator

不选用 基于类型声明初始化props。因为如果这么做会丢失设置默认值的能力 文档指路 在这种情况下正常来说虽然可以通过解构赋值来解决问题,但会导致可读性变差。

解构的参数只将被调用到的参数解构出来,没用到的自然不必定义。使用响应式Props解构是为了提高可读性(因为props.是非常多重复的)因此不能做太多本末倒置的工作

@liect liect changed the title [WIP]refactor: defineProps改为Vue3.5解构语法 refactor: defineProps改为Vue3.5解构语法 Dec 17, 2024
Copy link
Contributor

完成

@liect
Copy link
Contributor Author

liect commented Dec 17, 2024

不选用 基于类型声明初始化props。因为如果这么做会丢失设置默认值的能力 文档指路 在这种情况下正常来说虽然可以通过解构赋值来解决问题,但会导致可读性变差。

解构的参数只将被调用到的参数解构出来,没用到的自然不必定义。使用响应式Props解构是为了提高可读性(因为props.是非常多重复的)因此不能做太多本末倒置的工作

好的

@timi137137 timi137137 merged commit d235ea2 into Tencent:develop Dec 17, 2024
6 checks passed
@github-actions github-actions bot mentioned this pull request Jan 6, 2025
16 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants