uview-plus 3.0.3 → 3.0.4
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 +4 -4
- package/changelog.md +2 -0
- package/components/u--input/u--input.vue +2 -0
- package/components/u--textarea/u--textarea.vue +2 -0
- package/components/u-badge/props.js +5 -0
- package/components/u-cell/u-cell.vue +1 -0
- package/components/u-datetime-picker/props.js +9 -0
- package/components/u-datetime-picker/u-datetime-picker.vue +13 -0
- package/components/u-input/props.js +4 -0
- package/components/u-input/u-input.vue +30 -0
- package/components/u-number-box/props.js +9 -0
- package/components/u-number-box/u-number-box.vue +23 -0
- package/components/u-radio/u-radio.vue +7 -0
- package/components/u-radio-group/props.js +9 -1
- package/components/u-radio-group/u-radio-group.vue +18 -3
- package/components/u-rate/props.js +9 -0
- package/components/u-rate/u-rate.vue +16 -1
- package/components/u-switch/props.js +8 -0
- package/components/u-switch/u-switch.vue +26 -1
- package/components/u-textarea/props.js +5 -0
- package/components/u-textarea/u-textarea.vue +31 -1
- package/components/u-upload/u-upload.vue +3 -0
- package/index.js +3 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,16 +12,16 @@
|
|
|
12
12
|
|
|
13
13
|
## 说明
|
|
14
14
|
|
|
15
|
-
uview-plus,是
|
|
15
|
+
uview-plus,是uni-app全面兼容vue3/nvue的uni-app生态框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水。uview-plus是基于uView2.x移植的支持vue3的版本,感谢uView。
|
|
16
16
|
|
|
17
17
|
## [官方文档:https://uiadmin.net/uview-plus](https://uiadmin.net/uview-plus)
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
## 预览
|
|
21
21
|
|
|
22
|
-
您可以通过**微信**扫码,查看最佳的演示效果。
|
|
23
|
-
<br>
|
|
24
|
-
<br>
|
|
22
|
+
您可以通过**微信**扫码,查看最佳的演示效果。
|
|
23
|
+
<br>
|
|
24
|
+
<br>
|
|
25
25
|
<img src="https://uiadmin.net/uview-plus/common/h5_qrcode.png" width="220" height="220" >
|
|
26
26
|
|
|
27
27
|
## 链接
|
package/changelog.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<uvInput
|
|
3
3
|
:value="value"
|
|
4
|
+
:modelValue="modelValue"
|
|
4
5
|
:type="type"
|
|
5
6
|
:fixed="fixed"
|
|
6
7
|
:disabled="disabled"
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
@keyboardheightchange="$emit('keyboardheightchange')"
|
|
42
43
|
@change="e => $emit('change', e)"
|
|
43
44
|
@input="e => $emit('input', e)"
|
|
45
|
+
@update:modelValue="e => $emit('update:modelValue', e)"
|
|
44
46
|
@confirm="e => $emit('confirm', e)"
|
|
45
47
|
@clear="$emit('clear')"
|
|
46
48
|
@click="$emit('click')"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<uvTextarea
|
|
3
3
|
:value="value"
|
|
4
|
+
:modelValue="modelValue"
|
|
4
5
|
:placeholder="placeholder"
|
|
5
6
|
:height="height"
|
|
6
7
|
:confirmType="confirmType"
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
@linechange="e => $emit('linechange', e)"
|
|
28
29
|
@confirm="e => $emit('confirm')"
|
|
29
30
|
@input="e => $emit('input', e)"
|
|
31
|
+
@update:modelValue="e => $emit('update:modelValue', e)"
|
|
30
32
|
@keyboardheightchange="e => $emit('keyboardheightchange')"
|
|
31
33
|
></uvTextarea>
|
|
32
34
|
</template>
|
|
@@ -10,11 +10,20 @@ export default {
|
|
|
10
10
|
type: Boolean,
|
|
11
11
|
default: uni.$u.props.datetimePicker.showToolbar
|
|
12
12
|
},
|
|
13
|
+
// #ifdef VUE2
|
|
13
14
|
// 绑定值
|
|
14
15
|
value: {
|
|
15
16
|
type: [String, Number],
|
|
16
17
|
default: uni.$u.props.datetimePicker.value
|
|
17
18
|
},
|
|
19
|
+
// #endif
|
|
20
|
+
// #ifdef VUE3
|
|
21
|
+
// 绑定值
|
|
22
|
+
modelValue: {
|
|
23
|
+
type: [String, Number],
|
|
24
|
+
default: uni.$u.props.datetimePicker.value
|
|
25
|
+
},
|
|
26
|
+
// #endif
|
|
18
27
|
// 顶部标题
|
|
19
28
|
title: {
|
|
20
29
|
type: String,
|
|
@@ -95,9 +95,17 @@
|
|
|
95
95
|
mounted() {
|
|
96
96
|
this.init()
|
|
97
97
|
},
|
|
98
|
+
// #ifdef VUE3
|
|
99
|
+
emits: ['close', 'canel', 'confirm', 'change'],
|
|
100
|
+
// #endif
|
|
98
101
|
methods: {
|
|
99
102
|
init() {
|
|
103
|
+
// #ifdef VUE3
|
|
104
|
+
this.innerValue = this.correctValue(this.modelValue)
|
|
105
|
+
// #endif
|
|
106
|
+
// #ifdef VUE2
|
|
100
107
|
this.innerValue = this.correctValue(this.value)
|
|
108
|
+
// #endif
|
|
101
109
|
this.updateColumnValue(this.innerValue)
|
|
102
110
|
},
|
|
103
111
|
// 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用
|
|
@@ -120,7 +128,12 @@
|
|
|
120
128
|
value: this.innerValue,
|
|
121
129
|
mode: this.mode
|
|
122
130
|
})
|
|
131
|
+
// #ifdef VUE3
|
|
132
|
+
this.$emit('update:modelValue', this.innerValue)
|
|
133
|
+
// #endif
|
|
134
|
+
// #ifdef VUE2
|
|
123
135
|
this.$emit('input', this.innerValue)
|
|
136
|
+
// #endif
|
|
124
137
|
},
|
|
125
138
|
//用正则截取输出值,当出现多组数字时,抛出错误
|
|
126
139
|
intercept(e,type){
|
|
@@ -5,6 +5,10 @@ export default {
|
|
|
5
5
|
type: [String, Number],
|
|
6
6
|
default: uni.$u.props.input.value
|
|
7
7
|
},
|
|
8
|
+
modelValue: {
|
|
9
|
+
type: [String, Number],
|
|
10
|
+
default: uni.$u.props.input.value
|
|
11
|
+
},
|
|
8
12
|
// 输入框类型
|
|
9
13
|
// number-数字输入键盘,app-vue下可以输入浮点数,app-nvue和小程序平台下只能输入整数
|
|
10
14
|
// idcard-身份证输入键盘,微信、支付宝、百度、QQ小程序
|
|
@@ -136,6 +136,27 @@ export default {
|
|
|
136
136
|
};
|
|
137
137
|
},
|
|
138
138
|
watch: {
|
|
139
|
+
// #ifdef VUE3
|
|
140
|
+
modelValue: {
|
|
141
|
+
immediate: true,
|
|
142
|
+
handler(newVal, oldVal) {
|
|
143
|
+
this.innerValue = newVal;
|
|
144
|
+
/* #ifdef H5 */
|
|
145
|
+
// 在H5中,外部value变化后,修改input中的值,不会触发@input事件,此时手动调用值变化方法
|
|
146
|
+
if (
|
|
147
|
+
this.firstChange === false &&
|
|
148
|
+
this.changeFromInner === false
|
|
149
|
+
) {
|
|
150
|
+
this.valueChange();
|
|
151
|
+
}
|
|
152
|
+
/* #endif */
|
|
153
|
+
this.firstChange = false;
|
|
154
|
+
// 重置changeFromInner的值为false,标识下一次引起默认为外部引起的
|
|
155
|
+
this.changeFromInner = false;
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
// #endif
|
|
159
|
+
// #ifdef VUE2
|
|
139
160
|
value: {
|
|
140
161
|
immediate: true,
|
|
141
162
|
handler(newVal, oldVal) {
|
|
@@ -154,6 +175,7 @@ export default {
|
|
|
154
175
|
this.changeFromInner = false;
|
|
155
176
|
},
|
|
156
177
|
},
|
|
178
|
+
// #endif
|
|
157
179
|
},
|
|
158
180
|
computed: {
|
|
159
181
|
// 是否显示清除控件
|
|
@@ -204,6 +226,9 @@ export default {
|
|
|
204
226
|
return style;
|
|
205
227
|
},
|
|
206
228
|
},
|
|
229
|
+
// #ifdef VUE3
|
|
230
|
+
emits: ['update:modelValue', 'focus', 'blur', 'change', 'confirm', 'clear', 'keyboardheightchange'],
|
|
231
|
+
// #endif
|
|
207
232
|
methods: {
|
|
208
233
|
// 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用
|
|
209
234
|
setFormatter(e) {
|
|
@@ -251,7 +276,12 @@ export default {
|
|
|
251
276
|
valueChange() {
|
|
252
277
|
const value = this.innerValue;
|
|
253
278
|
this.$nextTick(() => {
|
|
279
|
+
// #ifdef VUE3
|
|
280
|
+
this.$emit("update:modelValue", value);
|
|
281
|
+
// #endif
|
|
282
|
+
// #ifdef VUE2
|
|
254
283
|
this.$emit("input", value);
|
|
284
|
+
// #endif
|
|
255
285
|
// 标识value值的变化是由内部引起的
|
|
256
286
|
this.changeFromInner = true;
|
|
257
287
|
this.$emit("change", value);
|
|
@@ -5,11 +5,20 @@ export default {
|
|
|
5
5
|
type: [String, Number],
|
|
6
6
|
default: uni.$u.props.numberBox.name
|
|
7
7
|
},
|
|
8
|
+
// #ifdef VUE2
|
|
8
9
|
// 用于双向绑定的值,初始化时设置设为默认min值(最小值)
|
|
9
10
|
value: {
|
|
10
11
|
type: [String, Number],
|
|
11
12
|
default: uni.$u.props.numberBox.value
|
|
12
13
|
},
|
|
14
|
+
// #endif
|
|
15
|
+
// #ifdef VUE3
|
|
16
|
+
// 用于双向绑定的值,初始化时设置设为默认min值(最小值)
|
|
17
|
+
modelValue: {
|
|
18
|
+
type: [String, Number],
|
|
19
|
+
default: uni.$u.props.numberBox.value
|
|
20
|
+
},
|
|
21
|
+
// #endif
|
|
13
22
|
// 最小值
|
|
14
23
|
min: {
|
|
15
24
|
type: [String, Number],
|
|
@@ -124,12 +124,22 @@
|
|
|
124
124
|
watchChange(n) {
|
|
125
125
|
this.check()
|
|
126
126
|
},
|
|
127
|
+
// #ifdef VUE2
|
|
127
128
|
// 监听v-mode的变化,重新初始化内部的值
|
|
128
129
|
value(n) {
|
|
129
130
|
if (n !== this.currentValue) {
|
|
130
131
|
this.currentValue = this.format(this.value)
|
|
131
132
|
}
|
|
133
|
+
},
|
|
134
|
+
// #endif
|
|
135
|
+
// #ifdef VUE3
|
|
136
|
+
// 监听v-mode的变化,重新初始化内部的值
|
|
137
|
+
modelValue(n) {
|
|
138
|
+
if (n !== this.currentValue) {
|
|
139
|
+
this.currentValue = this.format(this.modelValue)
|
|
140
|
+
}
|
|
132
141
|
}
|
|
142
|
+
// #endif
|
|
133
143
|
},
|
|
134
144
|
computed: {
|
|
135
145
|
getCursorSpacing() {
|
|
@@ -187,9 +197,17 @@
|
|
|
187
197
|
mounted() {
|
|
188
198
|
this.init()
|
|
189
199
|
},
|
|
200
|
+
// #ifdef VUE3
|
|
201
|
+
emits: ['update:modelValue', 'focus', 'blur', 'overlimit'],
|
|
202
|
+
// #endif
|
|
190
203
|
methods: {
|
|
191
204
|
init() {
|
|
205
|
+
// #ifdef VUE3
|
|
206
|
+
this.currentValue = this.format(this.modelValue)
|
|
207
|
+
// #endif
|
|
208
|
+
// #ifdef VUE2
|
|
192
209
|
this.currentValue = this.format(this.value)
|
|
210
|
+
// #endif
|
|
193
211
|
},
|
|
194
212
|
// 格式化整理数据,限制范围
|
|
195
213
|
format(value) {
|
|
@@ -278,7 +296,12 @@
|
|
|
278
296
|
// 如果开启了异步变更值,则不修改内部的值,需要用户手动在外部通过v-model变更
|
|
279
297
|
if (!this.asyncChange) {
|
|
280
298
|
this.$nextTick(() => {
|
|
299
|
+
// #ifdef VUE3
|
|
300
|
+
this.$emit('update:modelValue', value)
|
|
301
|
+
// #endif
|
|
302
|
+
// #ifdef VUE2
|
|
281
303
|
this.$emit('input', value)
|
|
304
|
+
// #endif
|
|
282
305
|
this.currentValue = value
|
|
283
306
|
this.$forceUpdate()
|
|
284
307
|
})
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
inactiveColor: null,
|
|
75
75
|
size: 18,
|
|
76
76
|
value: null,
|
|
77
|
+
modelValue: null,
|
|
77
78
|
iconColor: null,
|
|
78
79
|
placement: 'row',
|
|
79
80
|
borderBottom: false,
|
|
@@ -177,6 +178,7 @@
|
|
|
177
178
|
mounted() {
|
|
178
179
|
this.init()
|
|
179
180
|
},
|
|
181
|
+
|
|
180
182
|
methods: {
|
|
181
183
|
init() {
|
|
182
184
|
// 支付宝小程序不支持provide/inject,所以使用这个方法获取整个父组件,在created定义,避免循环引用
|
|
@@ -185,7 +187,12 @@
|
|
|
185
187
|
uni.$u.error('u-radio必须搭配u-radio-group组件使用')
|
|
186
188
|
}
|
|
187
189
|
// 设置初始化时,是否默认选中的状态
|
|
190
|
+
// #ifdef VUE3
|
|
191
|
+
this.checked = this.name === this.parentData.modelValue
|
|
192
|
+
// #endif
|
|
193
|
+
// #ifdef VUE2
|
|
188
194
|
this.checked = this.name === this.parentData.value
|
|
195
|
+
// #endif
|
|
189
196
|
},
|
|
190
197
|
updateParentData() {
|
|
191
198
|
this.getParentData('u-radio-group')
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
props: {
|
|
3
|
+
// #ifdef VUE3
|
|
4
|
+
// 绑定的值
|
|
5
|
+
modelValue: {
|
|
6
|
+
type: [String, Number, Boolean],
|
|
7
|
+
default: uni.$u.props.radioGroup.value
|
|
8
|
+
},
|
|
9
|
+
// #endif
|
|
10
|
+
// #ifdef VUE2
|
|
3
11
|
// 绑定的值
|
|
4
12
|
value: {
|
|
5
13
|
type: [String, Number, Boolean],
|
|
6
14
|
default: uni.$u.props.radioGroup.value
|
|
7
15
|
},
|
|
8
|
-
|
|
16
|
+
// #endif
|
|
9
17
|
// 是否禁用全部radio
|
|
10
18
|
disabled: {
|
|
11
19
|
type: Boolean,
|
|
@@ -42,9 +42,17 @@
|
|
|
42
42
|
// 所以需要手动通知子组件,这里返回一个parentData变量,供watch监听,在其中去通知每一个子组件重新从父组件(u-radio-group)
|
|
43
43
|
// 拉取父组件新的变化后的参数
|
|
44
44
|
parentData() {
|
|
45
|
-
|
|
45
|
+
// #ifdef VUE3
|
|
46
|
+
return [this.modelValue, this.disabled, this.inactiveColor, this.activeColor, this.size, this.labelDisabled, this.shape,
|
|
46
47
|
this.iconSize, this.borderBottom, this.placement
|
|
47
48
|
]
|
|
49
|
+
// #endif
|
|
50
|
+
// #ifdef VUE2
|
|
51
|
+
return [this.value, this.disabled, this.inactiveColor, this.activeColor, this.size, this.labelDisabled, this.shape,
|
|
52
|
+
this.iconSize, this.borderBottom, this.placement
|
|
53
|
+
]
|
|
54
|
+
// #endif
|
|
55
|
+
|
|
48
56
|
},
|
|
49
57
|
bemClass() {
|
|
50
58
|
// this.bem为一个computed变量,在mixin中
|
|
@@ -64,12 +72,14 @@
|
|
|
64
72
|
},
|
|
65
73
|
data() {
|
|
66
74
|
return {
|
|
67
|
-
|
|
68
75
|
}
|
|
69
76
|
},
|
|
70
77
|
created() {
|
|
71
78
|
this.children = []
|
|
72
79
|
},
|
|
80
|
+
// #ifdef VUE3
|
|
81
|
+
emits: ['update:modelValue', 'change'],
|
|
82
|
+
// #endif
|
|
73
83
|
methods: {
|
|
74
84
|
// 将其他的radio设置为未选中的状态
|
|
75
85
|
unCheckedOther(childInstance) {
|
|
@@ -83,7 +93,12 @@
|
|
|
83
93
|
name
|
|
84
94
|
} = childInstance
|
|
85
95
|
// 通过emit事件,设置父组件通过v-model双向绑定的值
|
|
86
|
-
|
|
96
|
+
// #ifdef VUE3
|
|
97
|
+
this.$emit("update:modelValue", name);
|
|
98
|
+
// #endif
|
|
99
|
+
// #ifdef VUE2
|
|
100
|
+
this.$emit("input", name);
|
|
101
|
+
// #endif
|
|
87
102
|
// 发出事件
|
|
88
103
|
this.$emit('change', name)
|
|
89
104
|
},
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
props: {
|
|
3
|
+
// #ifdef VUE3
|
|
4
|
+
// 用于v-model双向绑定选中的星星数量
|
|
5
|
+
modelValue: {
|
|
6
|
+
type: [String, Number],
|
|
7
|
+
default: uni.$u.props.rate.value
|
|
8
|
+
},
|
|
9
|
+
// #endif
|
|
10
|
+
// #ifdef VUE2
|
|
3
11
|
// 用于v-model双向绑定选中的星星数量
|
|
4
12
|
value: {
|
|
5
13
|
type: [String, Number],
|
|
6
14
|
default: uni.$u.props.rate.value
|
|
7
15
|
},
|
|
16
|
+
// #endif
|
|
8
17
|
// 要显示的星星数量
|
|
9
18
|
count: {
|
|
10
19
|
type: [String, Number],
|
|
@@ -116,11 +116,21 @@
|
|
|
116
116
|
};
|
|
117
117
|
},
|
|
118
118
|
watch: {
|
|
119
|
+
// #ifdef VUE3
|
|
120
|
+
modelValue(val) {
|
|
121
|
+
this.activeIndex = val;
|
|
122
|
+
},
|
|
123
|
+
// #endif
|
|
124
|
+
// #ifdef VUE2
|
|
119
125
|
value(val) {
|
|
120
126
|
this.activeIndex = val;
|
|
121
127
|
},
|
|
128
|
+
// #endif
|
|
122
129
|
activeIndex: 'emitEvent'
|
|
123
130
|
},
|
|
131
|
+
// #ifdef VUE3
|
|
132
|
+
emits: ['update:modelValue', 'change'],
|
|
133
|
+
// #endif
|
|
124
134
|
methods: {
|
|
125
135
|
init() {
|
|
126
136
|
uni.$u.sleep().then(() => {
|
|
@@ -202,8 +212,13 @@
|
|
|
202
212
|
emitEvent() {
|
|
203
213
|
// 发出change事件
|
|
204
214
|
this.$emit("change", this.activeIndex);
|
|
205
|
-
//
|
|
215
|
+
// 同时修改双向绑定的值
|
|
216
|
+
// #ifdef VUE3
|
|
217
|
+
this.$emit("update:modelValue", this.activeIndex);
|
|
218
|
+
// #endif
|
|
219
|
+
// #ifdef VUE2
|
|
206
220
|
this.$emit("input", this.activeIndex);
|
|
221
|
+
// #endif
|
|
207
222
|
},
|
|
208
223
|
// 获取当前激活的评分图标
|
|
209
224
|
getActiveIndex(x,isClick = false) {
|
|
@@ -26,10 +26,18 @@ export default {
|
|
|
26
26
|
default: uni.$u.props.switch.inactiveColor
|
|
27
27
|
},
|
|
28
28
|
// 通过v-model双向绑定的值
|
|
29
|
+
// #ifdef VUE3
|
|
30
|
+
modelValue: {
|
|
31
|
+
type: [Boolean, String, Number],
|
|
32
|
+
default: uni.$u.props.switch.value
|
|
33
|
+
},
|
|
34
|
+
// #endif
|
|
35
|
+
// #ifdef VUE2
|
|
29
36
|
value: {
|
|
30
37
|
type: [Boolean, String, Number],
|
|
31
38
|
default: uni.$u.props.switch.value
|
|
32
39
|
},
|
|
40
|
+
// #endif
|
|
33
41
|
// switch打开时的值
|
|
34
42
|
activeValue: {
|
|
35
43
|
type: [String, Number, Boolean],
|
|
@@ -52,6 +52,17 @@
|
|
|
52
52
|
name: "u-switch",
|
|
53
53
|
mixins: [uni.$u.mpMixin, uni.$u.mixin,props],
|
|
54
54
|
watch: {
|
|
55
|
+
// #ifdef VUE3
|
|
56
|
+
modelValue: {
|
|
57
|
+
immediate: true,
|
|
58
|
+
handler(n) {
|
|
59
|
+
if(n !== this.inactiveValue && n !== this.activeValue) {
|
|
60
|
+
uni.$u.error('v-model绑定的值必须为inactiveValue、activeValue二者之一')
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
// #endif
|
|
65
|
+
// #ifdef VUE2
|
|
55
66
|
value: {
|
|
56
67
|
immediate: true,
|
|
57
68
|
handler(n) {
|
|
@@ -60,6 +71,7 @@
|
|
|
60
71
|
}
|
|
61
72
|
}
|
|
62
73
|
}
|
|
74
|
+
// #endif
|
|
63
75
|
},
|
|
64
76
|
data() {
|
|
65
77
|
return {
|
|
@@ -68,7 +80,12 @@
|
|
|
68
80
|
},
|
|
69
81
|
computed: {
|
|
70
82
|
isActive(){
|
|
83
|
+
// #ifdef VUE3
|
|
84
|
+
return this.modelValue === this.activeValue;
|
|
85
|
+
// #endif
|
|
86
|
+
// #ifdef VUE2
|
|
71
87
|
return this.value === this.activeValue;
|
|
88
|
+
// #endif
|
|
72
89
|
},
|
|
73
90
|
switchStyle() {
|
|
74
91
|
let style = {}
|
|
@@ -108,12 +125,20 @@
|
|
|
108
125
|
return this.inactiveColor !== '#fff' && this.inactiveColor !== '#ffffff'
|
|
109
126
|
}
|
|
110
127
|
},
|
|
128
|
+
// #ifdef VUE3
|
|
129
|
+
emits: ['update:modelValue', 'change'],
|
|
130
|
+
// #endif
|
|
111
131
|
methods: {
|
|
112
132
|
clickHandler() {
|
|
113
133
|
if (!this.disabled && !this.loading) {
|
|
114
134
|
const oldValue = this.isActive ? this.inactiveValue : this.activeValue
|
|
115
135
|
if(!this.asyncChange) {
|
|
116
|
-
|
|
136
|
+
// #ifdef VUE3
|
|
137
|
+
this.$emit("update:modelValue", oldValue);
|
|
138
|
+
// #endif
|
|
139
|
+
// #ifdef VUE2
|
|
140
|
+
this.$emit("input", oldValue);
|
|
141
|
+
// #endif
|
|
117
142
|
}
|
|
118
143
|
// 放到下一个生命周期,因为双向绑定的value修改父组件状态需要时间,且是异步的
|
|
119
144
|
this.$nextTick(() => {
|
|
@@ -97,6 +97,7 @@ export default {
|
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
99
|
watch: {
|
|
100
|
+
// #ifdef VUE2
|
|
100
101
|
value: {
|
|
101
102
|
immediate: true,
|
|
102
103
|
handler(newVal, oldVal) {
|
|
@@ -115,6 +116,27 @@ export default {
|
|
|
115
116
|
this.changeFromInner = false;
|
|
116
117
|
},
|
|
117
118
|
},
|
|
119
|
+
// #endif
|
|
120
|
+
// #ifdef VUE3
|
|
121
|
+
modelValue: {
|
|
122
|
+
immediate: true,
|
|
123
|
+
handler(newVal, oldVal) {
|
|
124
|
+
this.innerValue = newVal;
|
|
125
|
+
/* #ifdef H5 */
|
|
126
|
+
// 在H5中,外部value变化后,修改input中的值,不会触发@input事件,此时手动调用值变化方法
|
|
127
|
+
if (
|
|
128
|
+
this.firstChange === false &&
|
|
129
|
+
this.changeFromInner === false
|
|
130
|
+
) {
|
|
131
|
+
this.valueChange();
|
|
132
|
+
}
|
|
133
|
+
/* #endif */
|
|
134
|
+
this.firstChange = false;
|
|
135
|
+
// 重置changeFromInner的值为false,标识下一次引起默认为外部引起的
|
|
136
|
+
this.changeFromInner = false;
|
|
137
|
+
},
|
|
138
|
+
}
|
|
139
|
+
// #endif
|
|
118
140
|
},
|
|
119
141
|
computed: {
|
|
120
142
|
// 组件的类名
|
|
@@ -146,6 +168,9 @@ export default {
|
|
|
146
168
|
return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle));
|
|
147
169
|
},
|
|
148
170
|
},
|
|
171
|
+
// #ifdef VUE3
|
|
172
|
+
emits: ['update:modelValue', 'linechange', 'focus', 'blur', 'change', 'confirm', 'keyboardheightchange'],
|
|
173
|
+
// #endif
|
|
149
174
|
methods: {
|
|
150
175
|
// 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用
|
|
151
176
|
setFormatter(e) {
|
|
@@ -178,7 +203,12 @@ export default {
|
|
|
178
203
|
valueChange() {
|
|
179
204
|
const value = this.innerValue;
|
|
180
205
|
this.$nextTick(() => {
|
|
181
|
-
|
|
206
|
+
// #ifdef VUE3
|
|
207
|
+
this.$emit("update:modelValue", value);
|
|
208
|
+
// #endif
|
|
209
|
+
// #ifdef VUE2
|
|
210
|
+
this.$emit("input", value);
|
|
211
|
+
// #endif
|
|
182
212
|
// 标识value值的变化是由内部引起的
|
|
183
213
|
this.changeFromInner = true;
|
|
184
214
|
this.$emit("change", value);
|
package/index.js
CHANGED
|
@@ -68,6 +68,9 @@ const install = (Vue) => {
|
|
|
68
68
|
// #ifndef APP-NVUE
|
|
69
69
|
// 只有vue,挂载到Vue.prototype才有意义,因为nvue中全局Vue.prototype和Vue.mixin是无效的
|
|
70
70
|
Vue.config.globalProperties.$u = $u
|
|
71
|
+
Vue.config.globalProperties.$nextTick = (cb) => {
|
|
72
|
+
cb();
|
|
73
|
+
}
|
|
71
74
|
Vue.mixin(mixin)
|
|
72
75
|
// #endif
|
|
73
76
|
}
|
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"id": "uview-plus",
|
|
3
3
|
"name": "uview-plus",
|
|
4
4
|
"displayName": "uview-plus3.0重磅发布,利剑出鞘,一统江湖",
|
|
5
|
-
"version": "3.0.
|
|
6
|
-
"description": "uview-plus
|
|
5
|
+
"version": "3.0.4",
|
|
6
|
+
"description": "uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"uview",
|
|
9
9
|
"uview-plus",
|