@wya/vc

wya for vue@3.x components
17,983 2
Install
npm install @wya/vc@2.1.1
Latest Version:2.1.1
Vue:2 · 3
License:MIT
Last Updated:May 10, 2026
Links: GitHub  ·  npm
Maintainer: wya

基于Vue@2.x的组件库移步@wya/vc

TODO

  • 文档建设
  • 测试用例覆盖(目前测试用例来自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

provide('[组件名]', {
	// 当前组件的props,
	props, 

	// 其他需要传递的字段
	[key: string]: https://github.com/wya-team/wya-vc.next/blob/HEAD/any
})

hooks 钩子相关

这里指单独未PC和Mobile组件提取hooks时,非公共hooks

  • 使用instance获取props和其他值(这个时候需要自行编写Props类型)

组件字段名统一

  • TODO

Related Packages

@wya/assist-vc
1,511 0

Version History

Version Released License
2.1.1 MIT
2.0.29 MIT
2.0.28 MIT
2.0.27 MIT
2.0.26 MIT
Pre-releases (250)
Version Released License
3.0.0-alpha.113 MIT
3.0.0-alpha.112 MIT
3.0.0-alpha.111 MIT
3.0.0-alpha.110 MIT
3.0.0-alpha.109 MIT