基于
[email protected]的组件库移步@wya/vc
- 文档建设
- 测试用例覆盖(目前测试用例来自Vue2.x未做修改)
- 适配TS,编译
- 主题建设
getCurrentInstance()以下统一叫instance
defineComponent有助于IDE检查TS(包括Mixin也需要)instance.ctx.$xxx: Vue2类似相关this.$xxx, 如可以使用ctx.$forceUpdate()(vite build时,不存在了, 不明未细查?)instance.ctx.$el与instance.vnode.el相同(前者在vite build的时候undefined, 不明未细查?)instance.parent可以寻找到父层@click事件作为函数使用的两种方式instance.vnode.props: 其中含事件如onClick, 可以将事件转化为函数使用inheritAttrs: false:onClick可以在attrs中获取当函数使用css和style在vue3中需要自行绑定,不存在响应式- 其他值和样式转为响应式:使用
hooks/use-attrs
- ESLint检查无报错
- TS类型检查无报错
import type { Ref } from 'vue'import type { xxx } from './types'
provide('[组件名]', {
// 当前组件的props,
props,
// 其他需要传递的字段
[key: string]: any
})
这里指单独未PC和Mobile组件提取hooks时,非公共hooks
- 使用
instance获取props和其他值(这个时候需要自行编写Props类型)
- TODO