@hlw-uni/mp-vue 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,64 +0,0 @@
1
- import { defineComponent } from 'vue';
2
-
3
- export interface MenuItem {
4
- key: string;
5
- label: string;
6
- icon?: string;
7
- value?: string;
8
- url?: string;
9
- action?: () => void;
10
- }
11
-
12
- export default defineComponent({
13
- name: 'MenuList',
14
- props: {
15
- items: { type: Array as () => MenuItem[], required: true },
16
- },
17
- emits: ['click'],
18
- setup(props, { emit }) {
19
- function onTap(item: MenuItem) {
20
- if (item.url) {
21
- uni.navigateTo({ url: item.url });
22
- } else if (item.action) {
23
- item.action();
24
- }
25
- emit('click', item);
26
- }
27
-
28
- return () => {
29
- const items = props.items.map((item) =>
30
- // @ts-ignore
31
- h('view', {
32
- class: 'hlw-menu-list__item',
33
- key: item.key,
34
- onClick: () => onTap(item),
35
- }, [
36
- // @ts-ignore
37
- h('view', { class: 'hlw-menu-list__left' }, [
38
- item.icon
39
- ? (
40
- // @ts-ignore
41
- h('text', { class: 'hlw-menu-list__icon' }, item.icon)
42
- )
43
- : null,
44
- // @ts-ignore
45
- h('text', { class: 'hlw-menu-list__label' }, item.label),
46
- ]),
47
- // @ts-ignore
48
- h('view', { class: 'hlw-menu-list__right' }, [
49
- item.value
50
- ? (
51
- // @ts-ignore
52
- h('text', { class: 'hlw-menu-list__value' }, item.value)
53
- )
54
- : null,
55
- // @ts-ignore
56
- h('text', { class: 'hlw-menu-list__arrow' }, '›'),
57
- ]),
58
- ]),
59
- );
60
- // @ts-ignore
61
- return h('view', { class: 'hlw-menu-list' }, items);
62
- };
63
- },
64
- });