wl-design-mobile 0.6.9 → 0.7.0
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.
- package/README.md +6 -6
- package/doc/img/styles/css/index.css +3 -3
- package/edit/list/styles/css/index.css +39 -39
- package/edit/select/lambo-edit-date.vue +2 -2
- package/package.json +1 -1
- package/search/lambo-week-select.vue +326 -0
- package/table/lambo-ag-table.vue +2 -4
- package/util/assist.js +43 -43
- package/util/bus.js +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# wl-design-mobile
|
|
2
|
-
|
|
3
|
-
## Setup
|
|
4
|
-
```
|
|
5
|
-
npm i wl-design-mobile
|
|
6
|
-
```
|
|
1
|
+
# wl-design-mobile
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
```
|
|
5
|
+
npm i wl-design-mobile
|
|
6
|
+
```
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
.img-upload-container {
|
|
2
|
-
padding: 0px 14px 12px 14px;
|
|
3
|
-
}
|
|
1
|
+
.img-upload-container {
|
|
2
|
+
padding: 0px 14px 12px 14px;
|
|
3
|
+
}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
.coll-div {
|
|
2
|
-
margin-bottom: 8px;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.indicator-title {
|
|
6
|
-
display: flex;
|
|
7
|
-
align-items: center;
|
|
8
|
-
color: var(--scl-blue);
|
|
9
|
-
font-size: 14px;
|
|
10
|
-
font-family: 微软雅黑, serif Regular;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.indicator-title .color-line {
|
|
14
|
-
width: 3px;
|
|
15
|
-
height: 14px;
|
|
16
|
-
margin-right: 8px;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.coll-title-icon {
|
|
20
|
-
justify-content: center;
|
|
21
|
-
align-items: center;
|
|
22
|
-
align-content: center;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/* 覆盖折叠面板的标题的padding */
|
|
26
|
-
/deep/ .van-cell {
|
|
27
|
-
padding: 12px 10px;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/* 覆盖去掉折叠面板的标题下面的线 */
|
|
31
|
-
/deep/ .van-cell::after {
|
|
32
|
-
border: none;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/* 覆盖折叠面板的内容的padding */
|
|
36
|
-
/deep/ .van-collapse-item__content {
|
|
37
|
-
padding: 0px 0px 0px 0px;
|
|
38
|
-
}
|
|
39
|
-
|
|
1
|
+
.coll-div {
|
|
2
|
+
margin-bottom: 8px;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.indicator-title {
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
color: var(--scl-blue);
|
|
9
|
+
font-size: 14px;
|
|
10
|
+
font-family: 微软雅黑, serif Regular;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.indicator-title .color-line {
|
|
14
|
+
width: 3px;
|
|
15
|
+
height: 14px;
|
|
16
|
+
margin-right: 8px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.coll-title-icon {
|
|
20
|
+
justify-content: center;
|
|
21
|
+
align-items: center;
|
|
22
|
+
align-content: center;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* 覆盖折叠面板的标题的padding */
|
|
26
|
+
/deep/ .van-cell {
|
|
27
|
+
padding: 12px 10px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* 覆盖去掉折叠面板的标题下面的线 */
|
|
31
|
+
/deep/ .van-cell::after {
|
|
32
|
+
border: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* 覆盖折叠面板的内容的padding */
|
|
36
|
+
/deep/ .van-collapse-item__content {
|
|
37
|
+
padding: 0px 0px 0px 0px;
|
|
38
|
+
}
|
|
39
|
+
|
|
@@ -52,11 +52,11 @@ export default {
|
|
|
52
52
|
},
|
|
53
53
|
minDate: {
|
|
54
54
|
type: Date,
|
|
55
|
-
default: () =>
|
|
55
|
+
default: () => moment().subtract(3, 'years').toDate(),
|
|
56
56
|
},
|
|
57
57
|
maxDate: {
|
|
58
58
|
type: Date,
|
|
59
|
-
default: () =>
|
|
59
|
+
default: () => moment().add(3, 'years').toDate(),
|
|
60
60
|
},
|
|
61
61
|
allowSameDay: {
|
|
62
62
|
type: Boolean,
|
package/package.json
CHANGED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="week-date-picker"
|
|
4
|
+
@touchstart="handleTouchStart"
|
|
5
|
+
@touchmove="handleTouchMove"
|
|
6
|
+
@touchend="handleTouchEnd"
|
|
7
|
+
@mousedown="handleMouseDown"
|
|
8
|
+
@mousemove="handleMouseMove"
|
|
9
|
+
@mouseup="handleMouseUp"
|
|
10
|
+
@mouseleave="handleMouseLeave"
|
|
11
|
+
>
|
|
12
|
+
<div class="week-days">
|
|
13
|
+
<div
|
|
14
|
+
v-for="day in weekDays"
|
|
15
|
+
:key="day.date.getTime()"
|
|
16
|
+
class="day-item"
|
|
17
|
+
:class="{
|
|
18
|
+
'today': day.isToday,
|
|
19
|
+
'active': day.isSelected,
|
|
20
|
+
}"
|
|
21
|
+
@click="selectDay(day)"
|
|
22
|
+
>
|
|
23
|
+
<div class="day-week">{{ day.weekDay }}</div>
|
|
24
|
+
<div class="day-month">{{ day.month }}月</div>
|
|
25
|
+
<div class="day-date">{{ day.date.getDate() }}</div>
|
|
26
|
+
<div v-if="day.isToday" class="today-dot"></div>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script>
|
|
33
|
+
const WEEK_DAYS = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
|
|
34
|
+
|
|
35
|
+
export default {
|
|
36
|
+
name: "LamboWeekSelect",
|
|
37
|
+
|
|
38
|
+
data() {
|
|
39
|
+
return {
|
|
40
|
+
selectedDate: new Date(),
|
|
41
|
+
weekStart: null,
|
|
42
|
+
startX: 0,
|
|
43
|
+
endX: 0,
|
|
44
|
+
isDragging: false,
|
|
45
|
+
swipeThreshold: 50,
|
|
46
|
+
clickDisabled: false
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
props: {
|
|
50
|
+
weekDate: {
|
|
51
|
+
type: String,
|
|
52
|
+
default: null
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
created() {
|
|
57
|
+
if (this.weekDate) {
|
|
58
|
+
this.initWithWeekDate(this.weekDate);
|
|
59
|
+
} else {
|
|
60
|
+
const today = new Date();
|
|
61
|
+
const todayStr = this.formatDateToYYYYMMDD(today);
|
|
62
|
+
this.initWithWeekDate(todayStr);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
computed: {
|
|
67
|
+
weekDays() {
|
|
68
|
+
if (!this.weekStart) return [];
|
|
69
|
+
return Array.from({length: 7}, (_, i) => {
|
|
70
|
+
const date = new Date(this.weekStart);
|
|
71
|
+
date.setDate(this.weekStart.getDate() + i);
|
|
72
|
+
const today = new Date();
|
|
73
|
+
return {
|
|
74
|
+
date,
|
|
75
|
+
month: date.getMonth() + 1,
|
|
76
|
+
weekDay: WEEK_DAYS[date.getDay()],
|
|
77
|
+
isToday: this.isSameDay(date, today),
|
|
78
|
+
isSelected: this.isSameDay(date, this.selectedDate)
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
methods: {
|
|
85
|
+
/**
|
|
86
|
+
* 根据YYYYMMDD格式的字符串初始化组件
|
|
87
|
+
* @param {string} dateFormat- 格式如:"20251205"
|
|
88
|
+
*/
|
|
89
|
+
initWithWeekDate(dateFormat) {
|
|
90
|
+
// 解析YYYYMMDD格式字符串为Date对象
|
|
91
|
+
const date = this.parseYYYYMMDD(dateFormat);
|
|
92
|
+
|
|
93
|
+
if (date) {
|
|
94
|
+
console.log("根据传入日期初始化:", dateFormat);
|
|
95
|
+
this.setWeekStart(date);
|
|
96
|
+
this.selectedDate = new Date(date);
|
|
97
|
+
} else {
|
|
98
|
+
console.log("日期解析失败,使用今天");
|
|
99
|
+
const today = new Date();
|
|
100
|
+
this.setWeekStart(today);
|
|
101
|
+
this.selectedDate = new Date(today);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 解析YYYYMMDD格式字符串为Date对象
|
|
107
|
+
* @param {string} yyyymmdd - 格式如:"20251205"
|
|
108
|
+
* @returns {Date|null} Date对象或null
|
|
109
|
+
*/
|
|
110
|
+
parseYYYYMMDD(dateFormat) {
|
|
111
|
+
if (!dateFormat || typeof dateFormat !== 'string' || dateFormat.length !== 8) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
const year = parseInt(dateFormat.substring(0, 4));
|
|
117
|
+
const month = parseInt(dateFormat.substring(4, 6)) - 1;
|
|
118
|
+
const day = parseInt(dateFormat.substring(6, 8));
|
|
119
|
+
|
|
120
|
+
const date = new Date(year, month, day);
|
|
121
|
+
|
|
122
|
+
// 验证日期是否有效
|
|
123
|
+
if (isNaN(date.getTime()) ||
|
|
124
|
+
date.getFullYear() !== year ||
|
|
125
|
+
date.getMonth() !== month ||
|
|
126
|
+
date.getDate() !== day) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return date;
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.error("日期解析错误:", error);
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
setWeekStart(date) {
|
|
138
|
+
const d = new Date(date);
|
|
139
|
+
const day = d.getDay();
|
|
140
|
+
const diff = d.getDate() - (day === 0 ? 6 : day - 1);
|
|
141
|
+
d.setDate(diff);
|
|
142
|
+
d.setHours(0, 0, 0, 0);
|
|
143
|
+
this.weekStart = d;
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
isSameDay(d1, d2) {
|
|
147
|
+
if (!d1 || !d2) return false;
|
|
148
|
+
return d1.toDateString() === d2.toDateString();
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
formatDateToYYYYMMDD(date) {
|
|
152
|
+
const year = date.getFullYear();
|
|
153
|
+
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
154
|
+
const day = date.getDate().toString().padStart(2, '0');
|
|
155
|
+
return `${year}${month}${day}`;
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
selectDay(day) {
|
|
159
|
+
if (this.clickDisabled) {
|
|
160
|
+
this.clickDisabled = false;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
this.selectedDate = new Date(day.date);
|
|
164
|
+
const clickDate = this.formatDateToYYYYMMDD(this.selectedDate);
|
|
165
|
+
console.log('选中的日期:', clickDate);
|
|
166
|
+
// 触发自定义事件,传递YYYYMMDD格式的日期
|
|
167
|
+
this.$emit('click', clickDate);
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
goPrevWeek() {
|
|
171
|
+
const newWeekStart = new Date(this.weekStart);
|
|
172
|
+
newWeekStart.setDate(this.weekStart.getDate() - 7);
|
|
173
|
+
this.setWeekStart(newWeekStart);
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
goNextWeek() {
|
|
177
|
+
const newWeekStart = new Date(this.weekStart);
|
|
178
|
+
newWeekStart.setDate(this.weekStart.getDate() + 7);
|
|
179
|
+
this.setWeekStart(newWeekStart);
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
handleTouchStart(e) {
|
|
183
|
+
this.startX = e.touches[0].clientX;
|
|
184
|
+
this.endX = this.startX;
|
|
185
|
+
this.isDragging = true;
|
|
186
|
+
this.clickDisabled = false;
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
handleTouchMove(e) {
|
|
190
|
+
if (!this.isDragging) return;
|
|
191
|
+
this.endX = e.touches[0].clientX;
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
handleTouchEnd() {
|
|
195
|
+
if (!this.isDragging) return;
|
|
196
|
+
|
|
197
|
+
const deltaX = this.endX - this.startX;
|
|
198
|
+
this.handleSwipe(deltaX);
|
|
199
|
+
|
|
200
|
+
this.isDragging = false;
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
handleMouseDown(e) {
|
|
204
|
+
this.startX = e.clientX;
|
|
205
|
+
this.endX = this.startX;
|
|
206
|
+
this.isDragging = true;
|
|
207
|
+
this.clickDisabled = false;
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
handleMouseMove(e) {
|
|
211
|
+
if (!this.isDragging) return;
|
|
212
|
+
this.endX = e.clientX;
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
handleMouseUp() {
|
|
216
|
+
if (!this.isDragging) return;
|
|
217
|
+
|
|
218
|
+
const deltaX = this.endX - this.startX;
|
|
219
|
+
this.handleSwipe(deltaX);
|
|
220
|
+
|
|
221
|
+
this.isDragging = false;
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
handleMouseLeave() {
|
|
225
|
+
this.isDragging = false;
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
handleSwipe(deltaX) {
|
|
229
|
+
if (Math.abs(deltaX) > this.swipeThreshold) {
|
|
230
|
+
this.clickDisabled = true;
|
|
231
|
+
if (deltaX > 0) {
|
|
232
|
+
this.goPrevWeek();
|
|
233
|
+
} else {
|
|
234
|
+
this.goNextWeek();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
</script>
|
|
241
|
+
|
|
242
|
+
<style scoped>
|
|
243
|
+
.week-date-picker {
|
|
244
|
+
width: 100%;
|
|
245
|
+
background: white;
|
|
246
|
+
padding: 16px 0;
|
|
247
|
+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
|
248
|
+
user-select: none;
|
|
249
|
+
border-radius: 8px;
|
|
250
|
+
overflow: hidden;
|
|
251
|
+
cursor: grab;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.week-date-picker:active {
|
|
255
|
+
cursor: grabbing;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.week-days {
|
|
259
|
+
display: flex;
|
|
260
|
+
justify-content: space-around;
|
|
261
|
+
align-items: center;
|
|
262
|
+
padding: 0 8px;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.day-item {
|
|
266
|
+
display: flex;
|
|
267
|
+
flex-direction: column;
|
|
268
|
+
align-items: center;
|
|
269
|
+
justify-content: center;
|
|
270
|
+
width: 44px;
|
|
271
|
+
height: 64px;
|
|
272
|
+
border-radius: 8px;
|
|
273
|
+
cursor: pointer;
|
|
274
|
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
275
|
+
position: relative;
|
|
276
|
+
flex-shrink: 0;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.day-item:hover {
|
|
280
|
+
background-color: #f5f5f5;
|
|
281
|
+
transform: translateY(-2px);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.day-item.active {
|
|
285
|
+
background-color: #1677ff;
|
|
286
|
+
box-shadow: 0 4px 12px rgba(22, 119, 255, 0.3);
|
|
287
|
+
transform: translateY(-2px);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.day-item.active .day-week,
|
|
291
|
+
.day-item.active .day-month,
|
|
292
|
+
.day-item.active .day-date {
|
|
293
|
+
color: white;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.day-week {
|
|
297
|
+
font-size: 12px;
|
|
298
|
+
color: #666;
|
|
299
|
+
margin-bottom: 4px;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.day-month {
|
|
303
|
+
font-size: 10px;
|
|
304
|
+
color: #999;
|
|
305
|
+
margin-bottom: 2px;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.day-date {
|
|
309
|
+
font-size: 20px;
|
|
310
|
+
font-weight: 500;
|
|
311
|
+
color: #333;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.today-dot {
|
|
315
|
+
position: absolute;
|
|
316
|
+
bottom: -4px;
|
|
317
|
+
width: 4px;
|
|
318
|
+
height: 4px;
|
|
319
|
+
background-color: #1677ff;
|
|
320
|
+
border-radius: 50%;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.day-item.active .today-dot {
|
|
324
|
+
background-color: white;
|
|
325
|
+
}
|
|
326
|
+
</style>
|
package/table/lambo-ag-table.vue
CHANGED
|
@@ -38,15 +38,13 @@ import 'ag-grid-community/styles/ag-grid.css'
|
|
|
38
38
|
import 'ag-grid-community/styles/ag-theme-balham.css'
|
|
39
39
|
/**
|
|
40
40
|
* 打包时候把这一行放开,下面的一行注释掉
|
|
41
|
-
*
|
|
41
|
+
*
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
import {AgGridVue} from 'ag-grid-vue/lib/main.cjs.js'
|
|
44
44
|
/**
|
|
45
45
|
* 本地运行的时候,把这一行放开,上面的一行注释掉
|
|
46
46
|
* import {AgGridVue} from 'ag-grid-vue'
|
|
47
47
|
*/
|
|
48
|
-
import {AgGridVue} from 'ag-grid-vue'
|
|
49
|
-
|
|
50
48
|
import {Toast} from "vant"
|
|
51
49
|
import {axios} from "../util/axios"
|
|
52
50
|
|
package/util/assist.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
// 深拷贝
|
|
2
|
-
export function deepCopy(data) {
|
|
3
|
-
let i;
|
|
4
|
-
const t = typeOf(data);
|
|
5
|
-
let o;
|
|
6
|
-
|
|
7
|
-
if (t === 'array') {
|
|
8
|
-
o = [];
|
|
9
|
-
} else if (t === 'object') {
|
|
10
|
-
o = {};
|
|
11
|
-
} else {
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (t === 'array') {
|
|
16
|
-
for (i = 0; i < data.length; i++) {
|
|
17
|
-
o.push(deepCopy(data[i]));
|
|
18
|
-
}
|
|
19
|
-
} else if (t === 'object') {
|
|
20
|
-
for (i in data) {
|
|
21
|
-
o[i] = deepCopy(data[i]);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return o;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// 判断对象类型
|
|
28
|
-
export function typeOf(obj) {
|
|
29
|
-
const toString = Object.prototype.toString;
|
|
30
|
-
const map = {
|
|
31
|
-
'[object Boolean]': 'boolean',
|
|
32
|
-
'[object Number]': 'number',
|
|
33
|
-
'[object String]': 'string',
|
|
34
|
-
'[object Function]': 'function',
|
|
35
|
-
'[object Array]': 'array',
|
|
36
|
-
'[object Date]': 'date',
|
|
37
|
-
'[object RegExp]': 'regExp',
|
|
38
|
-
'[object Undefined]': 'undefined',
|
|
39
|
-
'[object Null]': 'null',
|
|
40
|
-
'[object Object]': 'object'
|
|
41
|
-
};
|
|
42
|
-
return map[toString.call(obj)];
|
|
43
|
-
}
|
|
1
|
+
// 深拷贝
|
|
2
|
+
export function deepCopy(data) {
|
|
3
|
+
let i;
|
|
4
|
+
const t = typeOf(data);
|
|
5
|
+
let o;
|
|
6
|
+
|
|
7
|
+
if (t === 'array') {
|
|
8
|
+
o = [];
|
|
9
|
+
} else if (t === 'object') {
|
|
10
|
+
o = {};
|
|
11
|
+
} else {
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (t === 'array') {
|
|
16
|
+
for (i = 0; i < data.length; i++) {
|
|
17
|
+
o.push(deepCopy(data[i]));
|
|
18
|
+
}
|
|
19
|
+
} else if (t === 'object') {
|
|
20
|
+
for (i in data) {
|
|
21
|
+
o[i] = deepCopy(data[i]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return o;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 判断对象类型
|
|
28
|
+
export function typeOf(obj) {
|
|
29
|
+
const toString = Object.prototype.toString;
|
|
30
|
+
const map = {
|
|
31
|
+
'[object Boolean]': 'boolean',
|
|
32
|
+
'[object Number]': 'number',
|
|
33
|
+
'[object String]': 'string',
|
|
34
|
+
'[object Function]': 'function',
|
|
35
|
+
'[object Array]': 'array',
|
|
36
|
+
'[object Date]': 'date',
|
|
37
|
+
'[object RegExp]': 'regExp',
|
|
38
|
+
'[object Undefined]': 'undefined',
|
|
39
|
+
'[object Null]': 'null',
|
|
40
|
+
'[object Object]': 'object'
|
|
41
|
+
};
|
|
42
|
+
return map[toString.call(obj)];
|
|
43
|
+
}
|
package/util/bus.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Vue from 'vue'
|
|
2
|
-
|
|
3
|
-
const Bus = new Vue();
|
|
4
|
-
export default Bus;
|
|
1
|
+
import Vue from 'vue'
|
|
2
|
+
|
|
3
|
+
const Bus = new Vue();
|
|
4
|
+
export default Bus;
|