# h5-activity-components
**Repository Path**: guome/h5-activity-components
## Basic Information
- **Project Name**: h5-activity-components
- **Description**: H5活动组件
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 4
- **Forks**: 0
- **Created**: 2021-12-02
- **Last Updated**: 2024-10-24
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# H5常用活动组件
大转盘,刮刮乐组件
## 安装
```shell
$ yarn add h5-activity-components
```
## 使用
全局注册
```tsx
import { createApp } from 'vue'
import App from './App.vue'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import H5ActivityComponents from 'h5-activity-components'
import 'h5-activity-components/dist/style.css'
createApp(App)
.use(H5ActivityComponents)
.mount('#app')
```
### 大转盘
注意:如果外层有 flex 布局需要再包一层,否则尺寸计算不出来[暂时不知道什么原因]
#### 基本使用
```html
```
#### props和emits
```tsx
export interface PrizeItemType {
icon: string; // 奖品图片
name: string; // 奖品名称
isPrize: number; // 该奖项是否为奖品,0为没中奖
weight: number; // 权重
// 自定义配置
meta?: {
[index: string]: any;
};
}
interface Props {
// 奖品列表
prizes?: PrizeItemType[];
// 总旋转时间 ms
duration?: number | string;
// 旋转圈数
circle?: number;
// 动画效果
mode?:
| "ease"
| "ease-in"
| "ease-out"
| "ease-in-out"
| "cubic-bezier(, , , )";
// 是否禁止旋转
disabled?: boolean;
// 禁止旋转的提示
message?: string;
// 点击抽奖字体大小
tipTextFontSize?: string;
// 点击抽奖字样
tipText?: string;
}
// eslint-disable-next-line no-undef
const emit = defineEmits<{
(e: "win", prize: PrizeItemType): void; // 中奖回调
(e: "miss", prize: PrizeItemType): void; // 未中奖回调
(e: "finish", prize: PrizeItemType): void; // 结束回调(不管有没有中奖)
(e: "trigger-disabled"): void; // 禁用点击的时候往外抛出的事件
}>();
```
#### 效果图

### 刮刮乐
#### 基本使用
```html
```
#### props和emit
```tsx
emits: [
"finish", // 结束
"start", // 开始刮
"trigger-disabled", // 禁用点击的时候往外抛出的事件
],
props: {
// 画笔粗细
lineWidth: {
type: Number,
default: 30,
},
// 刮开1/3面积的时候结束游戏
finishProportion: {
type: Number,
default: 1 / 3,
},
// 是否禁用
disabled: {
type: Boolean,
default: false,
},
// 盒子高度
height: {
type: [String, Number],
default: "200px",
},
},
```
#### slot
只有一个默认 slot [放内容/奖品的盒子]
#### 效果图

### 开发注意事项
在 setup 和 普通的 script 出现在一起的时候,普通的 script 必须写下面,否则组件无法使用会出现类似提示:invalid vnode type: symbol fragment symbol
```html
```