vdesign-ui 0.1.22 → 0.1.24-beta

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 (60) hide show
  1. package/dist/components/activityviews/index.vue +13 -11
  2. package/dist/components/button/index.vue +1 -1
  3. package/dist/components/checkbox/index.vue +0 -26
  4. package/dist/components/dropdown/index.vue +72 -69
  5. package/dist/components/dropdown/style.less +23 -1
  6. package/dist/components/empty/404-dark.png +0 -0
  7. package/dist/components/empty/404.png +0 -0
  8. package/dist/components/empty/index.vue +30 -2
  9. package/dist/components/empty/network-dark.png +0 -0
  10. package/dist/components/empty/network.png +0 -0
  11. package/dist/components/empty/nocoupons-dark.png +0 -0
  12. package/dist/components/empty/nocoupons.png +0 -0
  13. package/dist/components/empty/nodata-dark.png +0 -0
  14. package/dist/components/empty/nodata.png +0 -0
  15. package/dist/components/empty/nomargin-dark.png +0 -0
  16. package/dist/components/empty/nomargin.png +0 -0
  17. package/dist/components/empty/nonotice-dark.png +0 -0
  18. package/dist/components/empty/nonotice.png +0 -0
  19. package/dist/components/empty/noocomments-dark.png +0 -0
  20. package/dist/components/empty/noocomments.png +0 -0
  21. package/dist/components/empty/noorders-dark.png +0 -0
  22. package/dist/components/empty/noorders.png +0 -0
  23. package/dist/components/empty/noposition-dark.png +0 -0
  24. package/dist/components/empty/noposition.png +0 -0
  25. package/dist/components/empty/nosearch-dark.png +0 -0
  26. package/dist/components/empty/nosearch.png +0 -0
  27. package/dist/components/footer/index.vue +1 -1
  28. package/dist/components/footnav/footnav-item/index.vue +2 -6
  29. package/dist/components/icon/font/iconfont.css +59 -949
  30. package/dist/components/icon/font/iconfont.js +1 -1
  31. package/dist/components/input/index.vue +31 -8
  32. package/dist/components/input/style.less +0 -1
  33. package/dist/components/loading/img_status_loading_white_ani.svg +155 -0
  34. package/dist/components/loading/img_status_refresh_ani.svg +158 -0
  35. package/dist/components/loading/index.vue +4 -3
  36. package/dist/components/loading/style.less +1 -1
  37. package/dist/components/mixins/clickoutside.js +81 -81
  38. package/dist/components/pagebreak/index.vue +11 -5
  39. package/dist/components/radio/index.vue +3 -7
  40. package/dist/components/radio/style.css +213 -0
  41. package/dist/components/radio/style.less +5 -0
  42. package/dist/components/result/index.vue +1 -2
  43. package/dist/components/selector/index.vue +64 -31
  44. package/dist/components/selector/style.less +10 -0
  45. package/dist/components/slider/index.vue +0 -6
  46. package/dist/components/title/index.vue +1 -1
  47. package/dist/components/upload/index.vue +67 -189
  48. package/dist/img/img_status_loading_white_ani.b56fcfae.svg +155 -0
  49. package/dist/img/img_status_refresh_ani.d0e59f12.svg +158 -0
  50. package/dist/token.css +10 -2
  51. package/dist/vdesign-ui.common.js +888 -795
  52. package/dist/vdesign-ui.css +1 -1
  53. package/dist/vdesign-ui.umd.js +888 -795
  54. package/dist/vdesign-ui.umd.min.js +3 -3
  55. package/package.json +1 -1
  56. package/dist/components/loading/loading.png +0 -0
  57. package/dist/components/loading/refresh.png +0 -0
  58. package/dist/img/404-dark.775df5bb.png +0 -0
  59. package/dist/img/network-dark.11a147bb.png +0 -0
  60. package/dist/img/nodata-dark.b0ea0e39.png +0 -0
@@ -11,6 +11,7 @@
11
11
  :type="passwordIcon ? (passwordVisible ? 'text' : 'password') : type"
12
12
  :class="inputClasses"
13
13
  :disabled="disabled"
14
+ :readonly="readonly"
14
15
  :placeholder="placeholder"
15
16
  :value="currentValue"
16
17
  @input="handleInput"
@@ -28,6 +29,7 @@
28
29
  :rows="rows"
29
30
  :class="inputClasses"
30
31
  :disabled="disabled"
32
+ :readonly="readonly"
31
33
  :placeholder="placeholder"
32
34
  :value="currentValue"
33
35
  @focus="handleFocus"
@@ -37,12 +39,12 @@
37
39
  >
38
40
  </textarea>
39
41
  <div
40
- v-if="suffix || $slots.suffix || append || $slots.append || isWordLimitVisible"
42
+ v-if="suffix || clearable || $slots.suffix || append || $slots.append || isWordLimitVisible"
41
43
  class="vd-input-form__right"
42
44
  >
43
- <span v-if="suffix || $slots.suffix" class="vd-input-form__suffix">
45
+ <span v-if="(suffix || $slots.suffix) || showClear" class="vd-input-form__suffix">
44
46
  <slot name="suffix">
45
- <vd-icon name="icon_btn_clean" @click="handleClear"></vd-icon>
47
+ <vd-icon name="icon_btn_clean" @mousedown.prevent.native="handleClear"></vd-icon>
46
48
  </slot>
47
49
  </span>
48
50
  <span v-if="append || $slots.append" class="vd-input-form__append">
@@ -64,7 +66,7 @@
64
66
  class="vd-input-form__password"
65
67
  >
66
68
  <span v-if="passwordClose" class="vd-input-form__password--close">
67
- <vd-icon name="icon_btn_close" @click="handleClear"></vd-icon>
69
+ <vd-icon name="icon_btn_close" @mousedown.prevent.native="handleClear"></vd-icon>
68
70
  </span>
69
71
  <span v-if="passwordIcon" class="vd-input-form__password--password">
70
72
  <vd-icon
@@ -82,11 +84,14 @@
82
84
  :wrap="wrap"
83
85
  :class="inputClasses"
84
86
  :disabled="disabled"
87
+ :readonly="readonly"
85
88
  :placeholder="placeholder"
86
89
  :value="currentValue"
87
90
  :rows="rows"
88
91
  :name="name"
89
92
  @input="handleInput"
93
+ @focus="handleFocus"
94
+ @blur="handleBlur"
90
95
  :style="textareaStyles"
91
96
  >
92
97
  </textarea>
@@ -144,10 +149,6 @@ export default {
144
149
  passwordClose: {
145
150
  type: Boolean,
146
151
  },
147
- passwordType: {
148
- type: String,
149
- default: "icon_btn_eye_close",
150
- },
151
152
  form: {
152
153
  type: String,
153
154
  },
@@ -192,6 +193,8 @@ export default {
192
193
  type: Boolean,
193
194
  default: false,
194
195
  },
196
+ clearable:Boolean,
197
+ readonly:Boolean
195
198
  },
196
199
  data() {
197
200
  return {
@@ -200,9 +203,20 @@ export default {
200
203
  isOnComposition: false,
201
204
  textareaStyles: {},
202
205
  passwordVisible: false,
206
+ focused: false,
203
207
  };
204
208
  },
205
209
  computed: {
210
+ showClear() {
211
+ const show = (
212
+ this.clearable &&
213
+ this.focused &&
214
+ this.currentValue !== '' &&
215
+ !this.disabled &&
216
+ !this.readonly
217
+ );
218
+ return show;
219
+ },
206
220
  wrapClasses() {
207
221
  return [
208
222
  {
@@ -257,12 +271,18 @@ export default {
257
271
  },
258
272
  methods: {
259
273
  handleFocus(event) {
274
+ this.focused = true;
260
275
  if (this.form) {
261
276
  this.focusClass = true;
262
277
  }
263
278
  this.$emit("focus", event);
279
+
280
+ if (this.readonly) {
281
+ this.blur();
282
+ }
264
283
  },
265
284
  handleBlur(event) {
285
+ this.focused = false;
266
286
  if (this.form) {
267
287
  this.focusClass = false;
268
288
  }
@@ -319,6 +339,9 @@ export default {
319
339
  this.setCurrentValue("");
320
340
  this.$emit("change", e);
321
341
  this.$emit("clear");
342
+ this.$nextTick(() => {
343
+ this.focus();
344
+ });
322
345
  },
323
346
  handlePasswordVisible() {
324
347
  this.passwordVisible = !this.passwordVisible;
@@ -139,7 +139,6 @@
139
139
  &__right {
140
140
  display: inline-flex;
141
141
  align-items: center;
142
-
143
142
  .@{input-prefix-cls}__word-limit {
144
143
  text-align: end;
145
144
  color: var(--color-input-text-default);
@@ -0,0 +1,155 @@
1
+ <svg
2
+ fill="none"
3
+ width='100%'
4
+ height='100%'
5
+ viewBox="0 0 32 32"
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ xmlns:xlink="http://www.w3.org/1999/xlink"
8
+ >
9
+ <defs>
10
+ <style type="text/css">
11
+ <![CDATA[
12
+ @keyframes loading-animate1 {
13
+ 0% {
14
+ fill-opacity: 0.16;
15
+ }
16
+ 20% {
17
+ fill-opacity: 1;
18
+ }
19
+ 26% {
20
+ fill-opacity: 0.32;
21
+ }
22
+ 32% {
23
+ fill-opacity: 0.16;
24
+ }
25
+ 100% {
26
+ fill-opacity: 0.16;
27
+ }
28
+ }
29
+
30
+ @keyframes loading-animate2 {
31
+ 0% {
32
+ fill-opacity: 0.16;
33
+ }
34
+ 12% {
35
+ fill-opacity: 0.16;
36
+ }
37
+ 22% {
38
+ fill-opacity: 1;
39
+ }
40
+ 31% {
41
+ fill-opacity: 0.32;
42
+ }
43
+ 37% {
44
+ fill-opacity: 0.16;
45
+ }
46
+ 100% {
47
+ fill-opacity: 0.16;
48
+ }
49
+ }
50
+
51
+ @keyframes loading-animate3 {
52
+ 0% {
53
+ fill-opacity: 0.16;
54
+ }
55
+ 20% {
56
+ fill-opacity: 0.16;
57
+ }
58
+ 30% {
59
+ fill-opacity: 1;
60
+ }
61
+ 36% {
62
+ fill-opacity: 0.32;
63
+ }
64
+ 42% {
65
+ fill-opacity: 0.16;
66
+ }
67
+ 100% {
68
+ fill-opacity: 0.16;
69
+ }
70
+ }
71
+
72
+ @keyframes loading-animate4 {
73
+ 0% {
74
+ fill-opacity: 0.16;
75
+ }
76
+ 25% {
77
+ fill-opacity: 0.16;
78
+ }
79
+ 35% {
80
+ fill-opacity: 1;
81
+ }
82
+ 41% {
83
+ fill-opacity: 0.32;
84
+ }
85
+ 47% {
86
+ fill-opacity: 0.16;
87
+ }
88
+ 100% {
89
+ fill-opacity: 0.16;
90
+ }
91
+ }
92
+
93
+ .loading-part-1,
94
+ .loading-part-2,
95
+ .loading-part-3,
96
+ .loading-part-4 {
97
+ animation-duration: 1s;
98
+ animation-delay: 0s;
99
+ animation-timing-function: cubic-bezier(0.5, 0, 1, 1);
100
+ animation-iteration-count: infinite;
101
+ }
102
+
103
+ .loading-part-1 {
104
+ animation-name: loading-animate1;
105
+ }
106
+
107
+ .loading-part-2 {
108
+ animation-name: loading-animate2;
109
+ }
110
+
111
+ .loading-part-3 {
112
+ animation-name: loading-animate3;
113
+ }
114
+
115
+ .loading-part-4 {
116
+ animation-name: loading-animate4;
117
+ }
118
+ ]]>
119
+ </style>
120
+ </defs>
121
+ <g>
122
+ <path
123
+ class="loading-part-1"
124
+ fill-rule="evenodd"
125
+ clip-rule="evenodd"
126
+ d="M6 32.0001L9.72003 28.209C9.95076 27.9739 10.0803 27.655 10.0803 27.3225V16.2236L6.36035 20.0147C6.12963 20.2498 6 20.5687 6 20.9012V32.0001Z"
127
+ fill-opacity="0.16"
128
+ fill="#FFFFFF"
129
+ />
130
+ <path
131
+ class="loading-part-2"
132
+ fill-rule="evenodd"
133
+ clip-rule="evenodd"
134
+ d="M11.3068 26.559L15.0269 22.768C15.2576 22.5329 15.3872 22.214 15.3872 21.8815V2.71126L11.6672 6.50233C11.4364 6.73746 11.3068 7.05636 11.3068 7.38889V26.559Z"
135
+ fill-opacity="0.16"
136
+ fill="#FFFFFF"
137
+ />
138
+ <path
139
+ class="loading-part-3"
140
+ fill-rule="evenodd"
141
+ clip-rule="evenodd"
142
+ d="M16.6255 29.2742L20.3455 25.4832C20.5762 25.248 20.7059 24.9292 20.7059 24.5966V5.42644L16.9858 9.21751C16.7552 9.4526 16.6255 9.77154 16.6255 10.104V29.2742Z"
143
+ fill="#FFFFFF"
144
+ fill-opacity="0.16"
145
+ />
146
+ <path
147
+ class="loading-part-4"
148
+ fill-rule="evenodd"
149
+ clip-rule="evenodd"
150
+ d="M21.9196 15.7765L25.6396 11.9854C25.8703 11.7503 26 11.4314 26 11.0989V0L22.2799 3.79107C22.0492 4.02617 21.9196 4.3451 21.9196 4.67759V15.7765Z"
151
+ fill="#FFFFFF"
152
+ fill-opacity="0.16"
153
+ />
154
+ </g>
155
+ </svg>
@@ -0,0 +1,158 @@
1
+ <svg
2
+ fill="none"
3
+ width='100%'
4
+ height='100%'
5
+ viewBox="0 0 32 32"
6
+ xmlns="http://www.w3.org/2000/svg"
7
+ xmlns:xlink="http://www.w3.org/1999/xlink"
8
+ >
9
+ <defs>
10
+ <style type="text/css">
11
+ <![CDATA[
12
+ @keyframes refresh-animate1 {
13
+ 0% {
14
+ fill-opacity: 1;
15
+ }
16
+ 16.67% {
17
+ fill-opacity: 0.16;
18
+ }
19
+ 50% {
20
+ fill-opacity: 0.16;
21
+ }
22
+ 83.33% {
23
+ fill-opacity: 0.16;
24
+ }
25
+ 100% {
26
+ fill-opacity: 1;
27
+ }
28
+ }
29
+
30
+ @keyframes refresh-animate2 {
31
+ 0% {
32
+ fill-opacity: 0.16;
33
+ }
34
+ 16.67% {
35
+ fill-opacity: 1;
36
+ }
37
+ 33.33% {
38
+ fill-opacity: 0.16;
39
+ }
40
+ 50% {
41
+ fill-opacity: 0.16;
42
+ }
43
+ 66.67% {
44
+ fill-opacity: 0.16;
45
+ }
46
+ 83.33% {
47
+ fill-opacity: 1;
48
+ }
49
+ 100% {
50
+ fill-opacity: 0.16;
51
+ }
52
+ }
53
+
54
+ @keyframes refresh-animate3 {
55
+ 0% {
56
+ fill-opacity: 0.16;
57
+ }
58
+ 16.67% {
59
+ fill-opacity: 0.16;
60
+ }
61
+ 33.33% {
62
+ fill-opacity: 1;
63
+ }
64
+ 50% {
65
+ fill-opacity: 0.16;
66
+ }
67
+ 66.67% {
68
+ fill-opacity: 1;
69
+ }
70
+ 83.33% {
71
+ fill-opacity: 0.16;
72
+ }
73
+ 100% {
74
+ fill-opacity: 0.16;
75
+ }
76
+ }
77
+
78
+ @keyframes refresh-animate4 {
79
+ 0% {
80
+ fill-opacity: 0.16;
81
+ }
82
+ 33.33% {
83
+ fill-opacity: 0.16;
84
+ }
85
+ 50% {
86
+ fill-opacity: 1;
87
+ }
88
+ 66.67% {
89
+ fill-opacity: 0.16;
90
+ }
91
+ 100% {
92
+ fill-opacity: 0.16;
93
+ }
94
+ }
95
+
96
+ .loading-part-1,
97
+ .loading-part-2,
98
+ .loading-part-3,
99
+ .loading-part-4 {
100
+ animation-duration: 1000ms;
101
+ animation-delay: 0s;
102
+ animation-timing-function: ease-out;
103
+ animation-iteration-count: infinite;
104
+ }
105
+
106
+ .loading-part-1 {
107
+ animation-name: refresh-animate1;
108
+ }
109
+
110
+ .loading-part-2 {
111
+ animation-name: refresh-animate2;
112
+ }
113
+
114
+ .loading-part-3 {
115
+ animation-name: refresh-animate3;
116
+ }
117
+
118
+ .loading-part-4 {
119
+ animation-name: refresh-animate4;
120
+ }
121
+ ]]>
122
+ </style>
123
+ </defs>
124
+ <g>
125
+ <path
126
+ class="loading-part-1"
127
+ fill-rule="evenodd"
128
+ clip-rule="evenodd"
129
+ d="M6 32.0001L9.72003 28.209C9.95076 27.9739 10.0803 27.655 10.0803 27.3225V16.2236L6.36035 20.0147C6.12963 20.2498 6 20.5687 6 20.9012V32.0001Z"
130
+ fill-opacity="0.16"
131
+ fill="#1BC47D"
132
+ />
133
+ <path
134
+ class="loading-part-2"
135
+ fill-rule="evenodd"
136
+ clip-rule="evenodd"
137
+ d="M11.3068 26.559L15.0269 22.768C15.2576 22.5329 15.3872 22.214 15.3872 21.8815V2.71126L11.6672 6.50233C11.4364 6.73746 11.3068 7.05636 11.3068 7.38889V26.559Z"
138
+ fill-opacity="0.16"
139
+ fill="#1BC47D"
140
+ />
141
+ <path
142
+ class="loading-part-3"
143
+ fill-rule="evenodd"
144
+ clip-rule="evenodd"
145
+ d="M16.6255 29.2742L20.3455 25.4832C20.5762 25.248 20.7059 24.9292 20.7059 24.5966V5.42644L16.9858 9.21751C16.7552 9.4526 16.6255 9.77154 16.6255 10.104V29.2742Z"
146
+ fill="#1BC47D"
147
+ fill-opacity="0.16"
148
+ />
149
+ <path
150
+ class="loading-part-4"
151
+ fill-rule="evenodd"
152
+ clip-rule="evenodd"
153
+ d="M21.9196 15.7765L25.6396 11.9854C25.8703 11.7503 26 11.4314 26 11.0989V0L22.2799 3.79107C22.0492 4.02617 21.9196 4.3451 21.9196 4.67759V15.7765Z"
154
+ fill="#1BC47D"
155
+ fill-opacity="0.16"
156
+ />
157
+ </g>
158
+ </svg>
@@ -1,14 +1,15 @@
1
1
  <template>
2
2
  <div class="vd-loading-wrapper">
3
-
4
3
  <div class="vd-loading" v-if="loading">
5
4
  <slot>
6
- <img src="./loading.png" alt="">
5
+ <img src="./img_status_loading_white_ani.svg" alt="">
7
6
  </slot>
8
7
  <span class="vd-loading__text" v-if="text">{{ text }}</span>
9
8
  </div>
10
9
  <div class="vd-refresh" :class="refreshClasses" v-else>
11
- <img src="./refresh.png" alt="">
10
+ <slot>
11
+ <img src="./img_status_refresh_ani.svg" alt="">
12
+ </slot>
12
13
  </div>
13
14
  </div>
14
15
  </template>
@@ -1,6 +1,6 @@
1
1
 
2
2
  .vd-loading{
3
- position: absolute;
3
+ position: fixed;
4
4
  left: 50%;
5
5
  top: 50%;
6
6
  transform: translate(-50%, -50%);
@@ -1,81 +1,81 @@
1
- import Vue from 'vue';
2
- import { on } from './dom';
3
- // 定义一个空数组 nodeList,用于存储绑定了该指令的元素。
4
- const nodeList = [];
5
- //定义一个常量 ctx,用于标识特殊属性名。
6
- const ctx = '@@clickoutsideContext';
7
- // 定义一个变量 startClick,用于存储点击开始时的事件对象。
8
- let startClick;
9
- // 定义一个变量 seed,用作节点标识的种子。
10
- let seed = 0;
11
- // 在文档上添加一个 mousedown 事件监听器,用于记录点击开始时的事件对象。
12
- !Vue.prototype.$isServer && on(document, 'mousedown', e => (startClick = e));
13
- // 添加一个 mouseup 事件监听器。当鼠标放开时,
14
- !Vue.prototype.$isServer && on(document, 'mouseup', e => {
15
- // 遍历 nodeList 数组中的每个元素,并执行它们的 documentHandler 函数。
16
- nodeList.forEach(node => node[ctx].documentHandler(e, startClick));
17
- });
18
- // 创建一个处理文档点击事件的函数。
19
- // 该函数返回一个闭包函数,用于检查点击事件是否发生在绑定的元素外部,并执行相应的回调函数。
20
- function createDocumentHandler(el, binding, vnode) {
21
- return function (mouseup = {}, mousedown = {}) {
22
- if (!vnode ||
23
- !vnode.context ||
24
- !mouseup.target ||
25
- !mousedown.target ||
26
- el.contains(mouseup.target) ||
27
- el.contains(mousedown.target) ||
28
- el === mouseup.target ||
29
- (vnode.context.popperElm &&
30
- (vnode.context.popperElm.contains(mouseup.target) ||
31
- vnode.context.popperElm.contains(mousedown.target)))) return;
32
-
33
- if (binding.expression &&
34
- el[ctx].methodName &&
35
- vnode.context[el[ctx].methodName]) {
36
- vnode.context[el[ctx].methodName]();
37
- } else {
38
- el[ctx].bindingFn && el[ctx].bindingFn();
39
- }
40
- };
41
- }
42
-
43
- /**
44
- * v-clickoutside
45
- * @desc 点击元素外面才会触发的事件
46
- * @example
47
- * ```vue
48
- * <div v-element-clickoutside="handleClose">
49
- * ```
50
- */
51
- export default {
52
- // 将元素添加到 nodeList 数组中,并为该元素添加一个包含事件处理函数的特殊属性。
53
- bind(el, binding, vnode) {
54
- nodeList.push(el);
55
- const id = seed++;
56
- el[ctx] = {
57
- id,
58
- documentHandler: createDocumentHandler(el, binding, vnode),
59
- methodName: binding.expression,
60
- bindingFn: binding.value
61
- };
62
- },
63
- // 当指令所在组件的 VNode 更新时调用,更新元素的事件处理函数和绑定方法。
64
- update(el, binding, vnode) {
65
- el[ctx].documentHandler = createDocumentHandler(el, binding, vnode);
66
- el[ctx].methodName = binding.expression;
67
- el[ctx].bindingFn = binding.value;
68
- },
69
- // 从 nodeList 中移除对应的元素,并删除特殊属性。
70
- unbind(el) {
71
- let len = nodeList.length;
72
-
73
- for (let i = 0; i < len; i++) {
74
- if (nodeList[i][ctx].id === el[ctx].id) {
75
- nodeList.splice(i, 1);
76
- break;
77
- }
78
- }
79
- delete el[ctx];
80
- }
81
- };
1
+ import Vue from 'vue';
2
+ import { on } from './dom';
3
+ // 定义一个空数组 nodeList,用于存储绑定了该指令的元素。
4
+ const nodeList = [];
5
+ //定义一个常量 ctx,用于标识特殊属性名。
6
+ const ctx = '@@clickoutsideContext';
7
+ // 定义一个变量 startClick,用于存储点击开始时的事件对象。
8
+ let startClick;
9
+ // 定义一个变量 seed,用作节点标识的种子。
10
+ let seed = 0;
11
+ // 在文档上添加一个 mousedown 事件监听器,用于记录点击开始时的事件对象。
12
+ !Vue.prototype.$isServer && on(document, 'mousedown', e => (startClick = e));
13
+ // 添加一个 mouseup 事件监听器。当鼠标放开时,
14
+ !Vue.prototype.$isServer && on(document, 'mouseup', e => {
15
+ // 遍历 nodeList 数组中的每个元素,并执行它们的 documentHandler 函数。
16
+ nodeList.forEach(node => node[ctx].documentHandler(e, startClick));
17
+ });
18
+ // 创建一个处理文档点击事件的函数。
19
+ // 该函数返回一个闭包函数,用于检查点击事件是否发生在绑定的元素外部,并执行相应的回调函数。
20
+ function createDocumentHandler(el, binding, vnode) {
21
+ return function (mouseup = {}, mousedown = {}) {
22
+ if (!vnode ||
23
+ !vnode.context ||
24
+ !mouseup.target ||
25
+ !mousedown.target ||
26
+ el.contains(mouseup.target) ||
27
+ el.contains(mousedown.target) ||
28
+ el === mouseup.target ||
29
+ (vnode.context.popperElm &&
30
+ (vnode.context.popperElm.contains(mouseup.target) ||
31
+ vnode.context.popperElm.contains(mousedown.target)))) return;
32
+
33
+ if (binding.expression &&
34
+ el[ctx].methodName &&
35
+ vnode.context[el[ctx].methodName]) {
36
+ vnode.context[el[ctx].methodName](mouseup.target);
37
+ } else {
38
+ el[ctx].bindingFn && el[ctx].bindingFn();
39
+ }
40
+ };
41
+ }
42
+
43
+ /**
44
+ * v-clickoutside
45
+ * @desc 点击元素外面才会触发的事件
46
+ * @example
47
+ * ```vue
48
+ * <div v-element-clickoutside="handleClose">
49
+ * ```
50
+ */
51
+ export default {
52
+ // 将元素添加到 nodeList 数组中,并为该元素添加一个包含事件处理函数的特殊属性。
53
+ bind(el, binding, vnode) {
54
+ nodeList.push(el);
55
+ const id = seed++;
56
+ el[ctx] = {
57
+ id,
58
+ documentHandler: createDocumentHandler(el, binding, vnode),
59
+ methodName: binding.expression,
60
+ bindingFn: binding.value
61
+ };
62
+ },
63
+ // 当指令所在组件的 VNode 更新时调用,更新元素的事件处理函数和绑定方法。
64
+ update(el, binding, vnode) {
65
+ el[ctx].documentHandler = createDocumentHandler(el, binding, vnode);
66
+ el[ctx].methodName = binding.expression;
67
+ el[ctx].bindingFn = binding.value;
68
+ },
69
+ // 从 nodeList 中移除对应的元素,并删除特殊属性。
70
+ unbind(el) {
71
+ let len = nodeList.length;
72
+
73
+ for (let i = 0; i < len; i++) {
74
+ if (nodeList[i][ctx].id === el[ctx].id) {
75
+ nodeList.splice(i, 1);
76
+ break;
77
+ }
78
+ }
79
+ delete el[ctx];
80
+ }
81
+ };
@@ -8,7 +8,7 @@
8
8
  </template>
9
9
 
10
10
  <div class="vd-page-break__number" v-else>
11
- <span class="vd-page-break__number--active" v-html="number"></span>
11
+ <span class="vd-page-break__number--active" v-if="number">{{ number }}</span>
12
12
  <span class="vd-page-break__number--line">/</span>
13
13
  <span class="vd-page-break__number--total">{{ total }}</span>
14
14
  </div>
@@ -34,21 +34,27 @@ export default {
34
34
  total: {
35
35
  type: Number,
36
36
  default: 9
37
+ },
38
+ activePage: {
39
+ type: Number,
40
+ default: 1 // 默认显示第一页
37
41
  }
38
42
  },
39
43
  data() {
40
44
  return {
41
- currentPage: 1,
45
+ currentPage: this.activePage // 从外部传入的值初始化,
42
46
  }
43
47
  },
44
- computed: {
45
-
48
+ watch: {
49
+ activePage(newVal) {
50
+ this.currentPage = newVal; // 外部传入值变化时更新当前页
51
+ }
46
52
  },
47
53
  methods: {
48
54
  changePage(pageNumber) {
49
55
  if (pageNumber >= 1 && pageNumber <= this.totalPages) {
50
56
  this.currentPage = pageNumber;
51
- this.$emit('page-changed', pageNumber);
57
+ this.$emit('change', pageNumber);
52
58
  }
53
59
  },
54
60
  },