forked from jd-opensource/nutui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.js
105 lines (85 loc) · 2.4 KB
/
demo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
var nameLc = 'test';
var demoModel = function (nameLc) {
var temp = {
demo: `<template>
<div class="demo">
<h2>基础用法</h2>
<nut-cell>
<${nameLc} ></${nameLc}>
<${nameLc} ></${nameLc}>
</nut-cell>
</div>
</template>
<script lang="ts">
import { createComponent } from '../../utils/create';
const { createDemo } = createComponent('${nameLc}');
export default createDemo({
props: {},
setup() {
return {};
}
});
</script>
<style lang="scss" scoped>
.demo{
}
</style>
`,
vue: `<template>
<view :class="classes" @click="handleClick">
<view>{{ name }}</view>
<view>{{ txt }}</view>
</view>
</template>
<script lang="ts">
import { toRefs } from 'vue';
import { createComponent } from '../../utils/create';
const { componentName, create } = createComponent('${nameLc}');
export default create({
props: {
name: {
type: String,
default: ''
},
txt: {
type: String,
default: ''
}
},
components: {},
emits: ['click'],
setup(props, { emit }) {
console.log('componentName', componentName);
const { name, txt } = toRefs(props);
const handleClick = (event: Event) => {
emit('click', event);
};
return { name, txt, handleClick };
}
});
</script>
`,
doc: `# ${nameLc}组件
### 介绍
基于 xxxxxxx
### 安装
${''}
### 基础用法
## API
### Props
| 参数 | 说明 | 类型 | 默认值 |
|--------------|----------------------------------|--------|------------------|
| name | 图标名称或图片链接 | String | - |
| color | 图标颜色 | String | - |
| size | 图标大小,如 '20px' '2em' '2rem' | String | - |
| class-prefix | 类名前缀,用于使用自定义图标 | String | 'nutui-iconfont' |
| tag | HTML 标签 | String | 'i' |
### Events
| 事件名 | 说明 | 回调参数 |
|--------|----------------|--------------|
| click | 点击图标时触发 | event: Event |
`
};
return temp;
};
module.exports = demoModel;