@zykjcommon/questions 0.0.1

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.
Files changed (115) hide show
  1. package/.browserslistrc +3 -0
  2. package/.env +7 -0
  3. package/.env.buildTest +9 -0
  4. package/.env.development +9 -0
  5. package/.env.production +13 -0
  6. package/.env.test +12 -0
  7. package/@types/global.d.ts +33 -0
  8. package/@types/shims-vue.d.ts +6 -0
  9. package/@types/shims-vuex.d.ts +15 -0
  10. package/auto-imports.d.ts +6 -0
  11. package/babel.config.js +5 -0
  12. package/components.d.ts +23 -0
  13. package/design/App.vue +60 -0
  14. package/design/main.js +23 -0
  15. package/design/views/dialog/contentDialog.vue +18 -0
  16. package/design/views/dialog/contentDialog2.vue +18 -0
  17. package/design/views/dialog/contentDialog3.vue +19 -0
  18. package/design/views/exam/analysis.vue +208 -0
  19. package/design/views/exam/exam.vue +355 -0
  20. package/design/views/home/illustrate.vue +45 -0
  21. package/design/views/home/login.vue +43 -0
  22. package/design/vueMapper.js +8 -0
  23. package/design/vueMapperTree.js +2 -0
  24. package/dist/demo.html +1 -0
  25. package/dist/zykjcommon-questions.common.js +12817 -0
  26. package/dist/zykjcommon-questions.css +1 -0
  27. package/dist/zykjcommon-questions.umd.js +12836 -0
  28. package/dist/zykjcommon-questions.umd.min.js +18 -0
  29. package/index.js +10 -0
  30. package/package.json +61 -0
  31. package/public/favicon.ico +0 -0
  32. package/public/index.html +19 -0
  33. package/public/static/js/jquery.html2json.js +169 -0
  34. package/public/static/js/jquery.json2html.js +137 -0
  35. package/public/static/js/jquery.min.js +2 -0
  36. package/public/static/js/json2html.js +447 -0
  37. package/readme +8 -0
  38. package/src/App.vue +37 -0
  39. package/src/assets/img/afei.jpg +0 -0
  40. package/src/assets/img/audio-ico.gif +0 -0
  41. package/src/assets/img/audio-ico.png +0 -0
  42. package/src/assets/img/bc-type-bg.png +0 -0
  43. package/src/assets/img/big-close.png +0 -0
  44. package/src/assets/img/big-next.png +0 -0
  45. package/src/assets/img/big-pre.png +0 -0
  46. package/src/assets/img/book-bg.png +0 -0
  47. package/src/assets/img/checkbox-cur.png +0 -0
  48. package/src/assets/img/checkbox.png +0 -0
  49. package/src/assets/img/cpp-bg.png +0 -0
  50. package/src/assets/img/deer-logo.png +0 -0
  51. package/src/assets/img/header-bg-2.png +0 -0
  52. package/src/assets/img/header-bg.png +0 -0
  53. package/src/assets/img/illustrate-bg.png +0 -0
  54. package/src/assets/img/loading.gif +0 -0
  55. package/src/assets/img/login-bg.png +0 -0
  56. package/src/assets/img/login-box-bg.png +0 -0
  57. package/src/assets/img/login-box-logo.png +0 -0
  58. package/src/assets/img/logo.png +0 -0
  59. package/src/assets/img/logoByText.png +0 -0
  60. package/src/assets/img/py-bg.png +0 -0
  61. package/src/assets/img/pygame-bg.png +0 -0
  62. package/src/assets/img/radio-cur.png +0 -0
  63. package/src/assets/img/radio.png +0 -0
  64. package/src/assets/img/return-top-hover.png +0 -0
  65. package/src/assets/img/return-top.png +0 -0
  66. package/src/assets/img/sb3-bg.png +0 -0
  67. package/src/assets/img/star-ico.png +0 -0
  68. package/src/assets/img/tab-mark.png +0 -0
  69. package/src/assets/img/video-play-btn.png +0 -0
  70. package/src/assets/js/arms.js +16 -0
  71. package/src/assets/js/bus.js +14 -0
  72. package/src/assets/js/fun.js +883 -0
  73. package/src/assets/js/helper.js +575 -0
  74. package/src/assets/js/http.js +219 -0
  75. package/src/assets/js/md5.js +260 -0
  76. package/src/assets/js/rem.js +33 -0
  77. package/src/assets/js/validation.js +216 -0
  78. package/src/assets/js/zykjcommon-questions.umd.min.js +18 -0
  79. package/src/assets/logo.png +0 -0
  80. package/src/assets/scss/dialog/dialog.scss +144 -0
  81. package/src/assets/scss/exam/exam.scss +256 -0
  82. package/src/assets/scss/home/home.scss +222 -0
  83. package/src/assets/scss/index.scss +80 -0
  84. package/src/assets/scss/questions/index.scss +345 -0
  85. package/src/common/const.ts +15 -0
  86. package/src/components/common/ContentDialog.vue +172 -0
  87. package/src/components/common/IframeComponent.vue +101 -0
  88. package/src/components/common/Loading.vue +45 -0
  89. package/src/components/common/MediaLooker.vue +171 -0
  90. package/src/components/common/TextAreaEditor.vue +121 -0
  91. package/src/components/exam/QuestionCard.vue +494 -0
  92. package/src/components/exam/QuestionHeader.vue +87 -0
  93. package/src/components/exam/TimeCounter.vue +107 -0
  94. package/src/components/questions/QuestionReader.js +20 -0
  95. package/src/components/questions/Question_SingleChoice.vue +208 -0
  96. package/src/components/questions/buildEntry.js +12 -0
  97. package/src/components/questions/developmentEntry.js +11 -0
  98. package/src/components/questions/mixin.js +64 -0
  99. package/src/main.ts +176 -0
  100. package/src/router/exam.ts +50 -0
  101. package/src/router/index.ts +33 -0
  102. package/src/store/exam.ts +199 -0
  103. package/src/store/index.ts +22 -0
  104. package/src/types/common/index.ts +4 -0
  105. package/src/types/exam/exam.ts +10 -0
  106. package/src/views/exam/Analysis.vue +516 -0
  107. package/src/views/exam/Default.vue +28 -0
  108. package/src/views/exam/Exam.vue +594 -0
  109. package/src/views/exam/ReviewPaper.vue +178 -0
  110. package/src/views/exam/ReviewQuestion.vue +167 -0
  111. package/tasks/vueMapper.js +37 -0
  112. package/tasks/vueMapperTree.js +42 -0
  113. package/tsconfig.json +46 -0
  114. package/tslint.json +19 -0
  115. package/vue.config.js +107 -0
@@ -0,0 +1,447 @@
1
+ //Copyright (c) 2018 Crystalline Technologies
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'),
4
+ // to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5
+ // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+ //
7
+ // The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+ //
9
+ // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
11
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
+
13
+ var json2html = {
14
+
15
+ /* ---------------------------------------- Public Methods ------------------------------------------------ */
16
+ 'transform': function(json,transform,_options) {
17
+
18
+ //create the default output
19
+ var out = {'events':[],'html':''};
20
+
21
+ //default options (by default we don't allow events)
22
+ var options = {
23
+ 'events':false
24
+ };
25
+
26
+ //extend the options
27
+ options = json2html._extend(options,_options);
28
+
29
+ //Make sure we have a transform & json object
30
+ if( transform !== undefined || json !== undefined ) {
31
+
32
+ //Normalize strings to JSON objects if necessary
33
+ var obj = typeof json === 'string' ? JSON.parse(json) : json;
34
+
35
+ //Transform the object (using the options)
36
+ out = json2html._transform(obj, transform, options);
37
+ }
38
+
39
+ //determine if we need the events
40
+ // otherwise return just the html string
41
+ if(options.events) return(out);
42
+ else return( out.html );
43
+ },
44
+
45
+ /* ---------------------------------------- Private Methods ------------------------------------------------ */
46
+
47
+ //Extend options
48
+ '_extend':function(obj1,obj2){
49
+ var obj3 = {};
50
+ for (var attrname in obj1) { obj3[attrname] = obj1[attrname]; }
51
+ for (var attrname in obj2) { obj3[attrname] = obj2[attrname]; }
52
+ return obj3;
53
+ },
54
+
55
+ //Append results
56
+ '_append':function(obj1,obj2) {
57
+ var out = {'html':'','event':[]};
58
+ if(typeof obj1 !== 'undefined' && typeof obj2 !== 'undefined') {
59
+ out.html = obj1.html + obj2.html;
60
+
61
+ out.events = obj1.events.concat(obj2.events);
62
+ }
63
+
64
+ return(out);
65
+ },
66
+
67
+ //isArray (fix for IE prior to 9)
68
+ '_isArray':function(obj) {
69
+ return Object.prototype.toString.call(obj) === '[object Array]';
70
+ },
71
+
72
+ //Transform object
73
+ '_transform':function(json, transform, options) {
74
+
75
+ var elements = {'events':[],'html':''};
76
+
77
+ //Determine the type of this object
78
+ if(json2html._isArray(json)) {
79
+
80
+ //Itterrate through the array and add it to the elements array
81
+ var len=json.length;
82
+ for(var j=0;j<len;++j) {
83
+ //Apply the transform to this object and append it to the results
84
+ elements = json2html._append(elements,json2html._apply(json[j], transform, j, options));
85
+ }
86
+
87
+ } else if(typeof json === 'object') {
88
+
89
+ //Apply the transform to this object and append it to the results
90
+ elements = json2html._append(elements,json2html._apply(json, transform, undefined, options));
91
+ }
92
+
93
+ //Return the resulting elements
94
+ return(elements);
95
+ },
96
+
97
+ //Apply the transform at the second level
98
+ '_apply':function(obj, transform, index, options) {
99
+
100
+ var element = {'events':[],'html':''};
101
+
102
+ //Itterate through the transform and create html as needed
103
+ if(json2html._isArray(transform)) {
104
+
105
+ var t_len = transform.length;
106
+ for(var t=0; t < t_len; ++t) {
107
+ //transform the object and append it to the output
108
+ element = json2html._append(element,json2html._apply(obj, transform[t], index, options));
109
+ }
110
+
111
+ } else if(typeof transform === 'object') {
112
+
113
+ var _element = '<>';
114
+
115
+ //Add legacy support for tag
116
+ if(transform[_element] === undefined) _element = 'tag';
117
+
118
+ //Check to see if we have a valid element name
119
+ if( transform[_element] !== undefined ) {
120
+
121
+ //Get the element name (this can be tokenized)
122
+ var name = json2html._getValue(obj,transform,_element,index);
123
+
124
+ //Create a new element
125
+ element.html += '<' + name;
126
+
127
+ //Create a new object for the children
128
+ var children = {'events':[],'html':''};
129
+
130
+ //innerHTML
131
+ var html;
132
+
133
+ //Look into the properties of this transform
134
+ for (var key in transform) {
135
+
136
+ switch(key) {
137
+
138
+ //DEPRECATED (use <> instead)
139
+ case 'tag':
140
+
141
+ //HTML element to render
142
+ case '<>':
143
+ //Do nothing as we have already created the element
144
+ break;
145
+
146
+ //Encode as text
147
+ case 'text':
148
+ //Get the transform value associated with this key
149
+ var _transform = transform[key];
150
+
151
+ //Determine what kind of object this is
152
+ // array => NOT SUPPORTED
153
+ // other => text
154
+ if(json2html._isArray(_transform)) {
155
+ //NOT Supported
156
+ } else if(typeof _transform === 'function') {
157
+
158
+ //Get the result from the function
159
+ var temp = _transform.call(obj, obj, index);
160
+
161
+ //Don't allow arrays as return objects from functions
162
+ if(!json2html._isArray(temp)) {
163
+
164
+ //Determine what type of object was returned
165
+ switch(typeof temp){
166
+
167
+ //Not supported for text
168
+ case 'function':
169
+ case 'undefined':
170
+ case 'object':
171
+ break;
172
+
173
+ //Append as text
174
+ // string, number, boolean
175
+ default:
176
+ //Insure we encode as text first
177
+ children.html += json2html.toText(temp);
178
+ break;
179
+ }
180
+ }
181
+ } else {
182
+
183
+ //Get the encoded text associated with this element
184
+ html = json2html.toText( json2html._getValue(obj,transform,key,index) );
185
+ }
186
+ break;
187
+
188
+ //DEPRECATED (use HTML instead)
189
+ case 'children':
190
+
191
+ //Encode as HTML
192
+ // accepts Array of children, functions, string, number, boolean
193
+ case 'html':
194
+
195
+ //Get the transform value associated with this key
196
+ // added as key could be children or html
197
+ var _transform = transform[key];
198
+
199
+ //Determine what kind of object this is
200
+ // array & function => children
201
+ // other => html
202
+ if(json2html._isArray(_transform)) {
203
+
204
+ //Apply the transform to the children
205
+ children = json2html._append(children,json2html._apply(obj, _transform, index, options));
206
+ } else if(typeof _transform === 'function') {
207
+
208
+ //Get the result from the function
209
+ var temp = _transform.call(obj, obj, index);
210
+
211
+ //Don't allow arrays as return objects from functions
212
+ if(!json2html._isArray(temp)) {
213
+
214
+ //Determine what type of object was returned
215
+ switch(typeof temp){
216
+
217
+ //Only returned by json2html.transform or $.json2html calls
218
+ case 'object':
219
+ //make sure this object is a valid json2html response object
220
+ // we ignore all other objects (since we don't know how to represent them in html)
221
+ if(temp.html !== undefined && temp.events !== undefined) children = json2html._append(children,temp);
222
+ break;
223
+
224
+ //Not supported
225
+ case 'function':
226
+ case 'undefined':
227
+ break;
228
+
229
+ //Append to html
230
+ // string, number, boolean
231
+ default:
232
+ children.html += temp;
233
+ break;
234
+ }
235
+ }
236
+ } else {
237
+
238
+ //Get the HTML associated with this element
239
+ html = json2html._getValue(obj,transform,key,index);
240
+ }
241
+ break;
242
+
243
+ default:
244
+ //Add the property as a attribute if it's not a key one
245
+ var isEvent = false;
246
+
247
+ //Check if the first two characters are 'on' then this is an event
248
+ if( key.length > 2 )
249
+ if(key.substring(0,2).toLowerCase() == 'on') {
250
+
251
+ //Determine if we should add events
252
+ if(options.events) {
253
+
254
+ //if so then setup the event data
255
+ var data = {
256
+ 'action':transform[key],
257
+ 'obj':obj,
258
+ 'data':options.eventData,
259
+ 'index':index
260
+ };
261
+
262
+ //create a new id for this event
263
+ var id = json2html._guid();
264
+
265
+ //append the new event to this elements events
266
+ element.events[element.events.length] = {'id':id,'type':key.substring(2),'data':data};
267
+
268
+ //Insert temporary event property (json2html-event-id) into the element
269
+ element.html += " json2html-event-id-"+key.substring(2)+"='" + id + "'";
270
+ }
271
+ //this is an event
272
+ isEvent = true;
273
+ }
274
+
275
+ //If this wasn't an event AND we actually have a value then add it as a property
276
+ if( !isEvent){
277
+ //Get the value
278
+ var val = json2html._getValue(obj, transform, key, index);
279
+
280
+ //Make sure we have a value
281
+ if(val !== undefined) {
282
+ var out;
283
+
284
+ //Determine the output type of this value (wrap with quotes)
285
+ if(typeof val === 'string') out = '"' + val.replace(/"/g, '&quot;') + '"';
286
+ else out = val;
287
+
288
+ //create the name value pair
289
+ element.html += ' ' + key + '=' + out;
290
+ }
291
+ }
292
+ break;
293
+ }
294
+ }
295
+
296
+ //close the opening element
297
+ element.html += '>';
298
+
299
+ //add the innerHTML (if we have any)
300
+ if(html) element.html += html;
301
+
302
+ //add the children (if we have any)
303
+ element = json2html._append(element,children);
304
+
305
+ //add the closing element
306
+ element.html += '</' + name + '>';
307
+ }
308
+ }
309
+
310
+ //Return the output object
311
+ return(element);
312
+ },
313
+
314
+ //Get a new GUID (used by events)
315
+ '_guid':function() {
316
+ var S4 = function() {
317
+ return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
318
+ };
319
+ return (S4()+S4()+"-"+S4()+S4()+"-"+S4()+S4());
320
+ },
321
+
322
+ //Get the html value of the object
323
+ '_getValue':function(obj, transform, key,index) {
324
+
325
+ var out = '';
326
+
327
+ var val = transform[key];
328
+ var type = typeof val;
329
+
330
+ if (type === 'function') {
331
+ return(val.call(obj,obj,index));
332
+ } else if (type === 'string') {
333
+ var _tokenizer = new json2html._tokenizer([
334
+ /\$\{([^\}\{]+)\}/
335
+ ],function( src, real, re ){
336
+ return real ? src.replace(re,function(all,name){
337
+
338
+ //Split the string into it's seperate components
339
+ var components = name.split('.');
340
+
341
+ //Set the object we use to query for this name to be the original object
342
+ var useObj = obj;
343
+
344
+ //Output value
345
+ var outVal = '';
346
+
347
+ //Parse the object components
348
+ var c_len = components.length;
349
+ for (var i=0;i<c_len;++i) {
350
+
351
+ if( components[i].length > 0 ) {
352
+
353
+ var newObj = useObj[components[i]];
354
+ useObj = newObj;
355
+ if(useObj === null || useObj === undefined) break;
356
+ }
357
+ }
358
+
359
+ //As long as we have an object to use then set the out
360
+ if(useObj !== null && useObj !== undefined) outVal = useObj;
361
+
362
+ return(outVal);
363
+ }) : src;
364
+ });
365
+
366
+ out = _tokenizer.parse(val).join('');
367
+ } else {
368
+ out = val;
369
+ }
370
+
371
+ return(out);
372
+ },
373
+
374
+ //Encode the html to text
375
+ 'toText':function(html) {
376
+ return html
377
+ .replace(/&/g, '&amp;')
378
+ .replace(/</g, '&lt;')
379
+ .replace(/>/g, '&gt;')
380
+ .replace(/\"/g, '&quot;')
381
+ .replace(/\'/g, '&#39;')
382
+ .replace(/\//g, '&#x2F;');
383
+ },
384
+
385
+ //Tokenizer
386
+ '_tokenizer':function( tokenizers, doBuild ){
387
+
388
+ if( !(this instanceof json2html._tokenizer ) )
389
+ return new json2html._tokenizer( tokenizers, doBuild );
390
+
391
+ this.tokenizers = tokenizers.splice ? tokenizers : [tokenizers];
392
+ if( doBuild )
393
+ this.doBuild = doBuild;
394
+
395
+ this.parse = function( src ){
396
+ this.src = src;
397
+ this.ended = false;
398
+ this.tokens = [ ];
399
+ do {
400
+ this.next();
401
+ } while( !this.ended );
402
+ return this.tokens;
403
+ };
404
+
405
+ this.build = function( src, real ){
406
+ if( src )
407
+ this.tokens.push(
408
+ !this.doBuild ? src :
409
+ this.doBuild(src,real,this.tkn)
410
+ );
411
+ };
412
+
413
+ this.next = function(){
414
+ var self = this,
415
+ plain;
416
+
417
+ self.findMin();
418
+ plain = self.src.slice(0, self.min);
419
+
420
+ self.build( plain, false );
421
+
422
+ self.src = self.src.slice(self.min).replace(self.tkn,function( all ){
423
+ self.build(all, true);
424
+ return '';
425
+ });
426
+
427
+ if( !self.src )
428
+ self.ended = true;
429
+ };
430
+
431
+ this.findMin = function(){
432
+ var self = this, i=0, tkn, idx;
433
+ self.min = -1;
434
+ self.tkn = '';
435
+
436
+ while(( tkn = self.tokenizers[i++]) !== undefined ){
437
+ idx = self.src[tkn.test?'search':'indexOf'](tkn);
438
+ if( idx != -1 && (self.min == -1 || idx < self.min )){
439
+ self.tkn = tkn;
440
+ self.min = idx;
441
+ }
442
+ }
443
+ if( self.min == -1 )
444
+ self.min = self.src.length;
445
+ };
446
+ }
447
+ };
package/readme ADDED
@@ -0,0 +1,8 @@
1
+ 1.watch用这种
2
+ watch(() => props.questionList, (nv) => {
3
+ if(nv && nv.length){
4
+ responsiveObj.value.questionList = nv
5
+ }
6
+ },{immediate:true,deep:true})
7
+
8
+
package/src/App.vue ADDED
@@ -0,0 +1,37 @@
1
+ <template>
2
+ <router-view></router-view>
3
+ <!-- <remote-js :src="BASE_URL + 'static/js/jquery.min.js?_v=' + VUE_APP_VERSION"></remote-js>-->
4
+ <remote-js :src="BASE_URL + 'static/js/json2html.js?_v=' + VUE_APP_VERSION"></remote-js>
5
+ <remote-js :src="BASE_URL + 'static/js/jquery.json2html.js?_v=' + VUE_APP_VERSION"></remote-js>
6
+ <remote-js :src="BASE_URL + 'static/js/jquery.html2json.js?_v=' + VUE_APP_VERSION"></remote-js>
7
+ </template>
8
+ <script>
9
+ import fun from '@src/assets/js/fun.js';
10
+ import {mapMutations,mapState} from 'vuex'
11
+ import bus from "@/assets/js/bus";
12
+ export default {
13
+ name: "App",
14
+ provide(){
15
+ return {
16
+ routerReload:this.routerReload
17
+ }
18
+ },
19
+ methods:{
20
+ ...mapMutations(['setToken']),
21
+ },
22
+ computed:{
23
+
24
+ },
25
+ data: () => ({
26
+ BASE_URL:process.env.BASE_URL,
27
+ VUE_APP_VERSION:process.env.VUE_APP_VERSION
28
+ }),
29
+ mounted() {
30
+ },
31
+ watch:{
32
+ }
33
+ };
34
+ </script>
35
+ <style lang="scss">
36
+ @import "~@src/assets/scss/index.scss";
37
+ </style>
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 阿里前端监控
3
+ * 配置文档 https://www.npmjs.com/package/alife-logger
4
+ */
5
+ import BrowerLogger from 'alife-logger';
6
+ document.addEventListener('getStudentIdSuccess',()=>{
7
+ let __bl = BrowserLogger.singleton({
8
+ uid:window.applicant_id,
9
+ pid: 'g1i6fo9yme@eb5128566ad4fad', // 这是项目ID,新建一个应用站点后自动生成,在单个应用站点内部的`设置->应用设置`查看
10
+ imgUrl: 'https://arms-retcode.aliyuncs.com/r.png?', // 日志上传地址,源码中默认值就是这个地址
11
+ enableSPA: true, // 是否监听页面的 hashchange 事件并从新上报 PV,适用于单页面应用场景
12
+ sendResource: true, // 是否上报资源数据
13
+ environment:process.env.VUE_APP_ENV
14
+ })
15
+ console.log(__bl,3333);
16
+ })
@@ -0,0 +1,14 @@
1
+ import mitt from 'mitt';
2
+
3
+ // 初始化一个 mitt 实例
4
+ const emitter = mitt();
5
+
6
+ // 定义一个空对象用来承载我们的自定义方法
7
+ const bus = {};
8
+
9
+ // 把你要用到的方法添加到 bus 对象上
10
+ bus.$on = emitter.on;
11
+ bus.$emit = emitter.emit;
12
+
13
+ // 最终是暴露自己定义的 bus
14
+ export default bus;