# SDA2.0 组件库

## 安装启动

1. 安装依赖
   `$ yarn`

2. 启动项目
   `$ yarn dev`

## 发布版本

1. 登录 NPM 仓库
   `$ npm login`

2. 修改版本
   每次发布前需要更改 package.json version 字段, 提高版本号

3. 发布依赖

- 发布正式版本
  `$ npm publish`

- 添加 tag 发布测试版本
  `$ npm publish --tag=beta`

- 安装测试包
  `$ npm i <packageName>@beta`

## 组件定义示例

- 严禁使用 var 定义变量, require 引入文件

- [ref reactive toRef toRefs 的区别](https://blog.csdn.net/weixin_44867717/article/details/120531610)

```ts
import { defineComponent, h, toRef } from 'vue'

export default defineComponent({
  name: 'MLabel',
  props: {
    value: {
      type: String,
      required: true
    }
  },
  setup(props) {
    const label = toRef(props, 'value')

    return {
      label
    }
  },
  render() {
    return h('span', [`${this.label}`])
  }
})
```
