uview-plus 3.2.7 → 3.2.9
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/changelog.md +7 -0
- package/components/u--form/u--form.vue +7 -7
- package/components/u--image/u--image.vue +3 -3
- package/components/u--input/u--input.vue +9 -9
- package/components/u--textarea/u--textarea.vue +3 -3
- package/components/u-action-sheet/u-action-sheet.vue +5 -4
- package/components/u-album/u-album.vue +9 -7
- package/components/u-alert/u-alert.vue +9 -6
- package/components/u-avatar/props.js +2 -1
- package/components/u-avatar/u-avatar.vue +15 -11
- package/components/u-avatar-group/u-avatar-group.vue +9 -5
- package/components/u-back-top/u-back-top.vue +9 -8
- package/components/u-badge/u-badge.vue +10 -6
- package/components/u-button/u-button.vue +13 -9
- package/components/u-calendar/header.vue +3 -3
- package/components/u-calendar/month.vue +17 -15
- package/components/u-calendar/u-calendar.vue +10 -8
- package/components/u-car-keyboard/u-car-keyboard.vue +7 -6
- package/components/u-cell/u-cell.vue +9 -6
- package/components/u-cell-group/u-cell-group.vue +8 -4
- package/components/u-checkbox/u-checkbox.vue +13 -11
- package/components/u-checkbox-group/u-checkbox-group.vue +3 -3
- package/components/u-circle-progress/u-circle-progress.vue +5 -4
- package/components/u-code/u-code.vue +3 -3
- package/components/u-code-input/u-code-input.vue +9 -8
- package/components/u-col/u-col.vue +9 -8
- package/components/u-collapse/u-collapse.vue +3 -3
- package/components/u-collapse-item/u-collapse-item.vue +32 -15
- package/components/u-column-notice/u-column-notice.vue +8 -6
- package/components/u-count-down/u-count-down.vue +3 -3
- package/components/u-count-to/u-count-to.vue +6 -4
- package/components/u-datetime-picker/u-datetime-picker.vue +15 -15
- package/components/u-divider/u-divider.vue +7 -5
- package/components/u-dropdown/u-dropdown.vue +12 -10
- package/components/u-dropdown-item/u-dropdown-item.vue +7 -5
- package/components/u-empty/u-empty.vue +12 -8
- package/components/u-form/u-form.vue +12 -10
- package/components/u-form-item/u-form-item.vue +17 -11
- package/components/u-gap/u-gap.vue +3 -3
- package/components/u-grid/u-grid.vue +18 -7
- package/components/u-grid-item/u-grid-item.vue +14 -9
- package/components/u-icon/u-icon.vue +21 -19
- package/components/u-image/u-image.vue +18 -16
- package/components/u-index-anchor/u-index-anchor.vue +11 -9
- package/components/u-index-item/u-index-item.vue +6 -5
- package/components/u-index-list/u-index-list.vue +20 -18
- package/components/u-input/u-input.vue +12 -11
- package/components/u-keyboard/u-keyboard.vue +3 -3
- package/components/u-line/u-line.vue +7 -6
- package/components/u-line-progress/u-line-progress.vue +11 -8
- package/components/u-link/u-link.vue +9 -8
- package/components/u-list/u-list.vue +9 -9
- package/components/u-list-item/u-list-item.vue +5 -4
- package/components/u-loading-icon/u-loading-icon.vue +14 -10
- package/components/u-loading-page/u-loading-page.vue +10 -7
- package/components/u-loadmore/u-loadmore.vue +12 -10
- package/components/u-modal/u-modal.vue +7 -5
- package/components/u-navbar/u-navbar.vue +12 -7
- package/components/u-no-network/u-no-network.vue +6 -6
- package/components/u-notice-bar/u-notice-bar.vue +6 -5
- package/components/u-notify/u-notify.vue +19 -15
- package/components/u-number-box/u-number-box.vue +8 -7
- package/components/u-number-keyboard/u-number-keyboard.vue +7 -7
- package/components/u-overlay/u-overlay.vue +5 -5
- package/components/u-picker/u-picker.vue +19 -15
- package/components/u-picker-column/u-picker-column.vue +3 -3
- package/components/u-popup/u-popup.vue +13 -13
- package/components/u-radio/u-radio.vue +12 -12
- package/components/u-radio-group/u-radio-group.vue +3 -3
- package/components/u-rate/u-rate.vue +16 -14
- package/components/u-read-more/u-read-more.vue +9 -7
- package/components/u-row/u-row.vue +8 -7
- package/components/u-row-notice/u-row-notice.vue +14 -12
- package/components/u-safe-bottom/u-safe-bottom.vue +5 -4
- package/components/u-scroll-list/nvue.js +4 -4
- package/components/u-scroll-list/u-scroll-list.vue +13 -10
- package/components/u-search/u-search.vue +8 -6
- package/components/u-skeleton/u-skeleton.vue +20 -17
- package/components/u-slider/mpwxs.js +3 -2
- package/components/u-slider/nvue - /345/211/257/346/234/254.js" +2 -2
- package/components/u-slider/nvue.js +2 -2
- package/components/u-slider/u-slider.vue +8 -5
- package/components/u-status-bar/u-status-bar.vue +6 -5
- package/components/u-steps/u-steps.vue +5 -4
- package/components/u-steps-item/u-steps-item.vue +9 -7
- package/components/u-sticky/u-sticky.vue +12 -10
- package/components/u-subsection/u-subsection.vue +8 -6
- package/components/u-swipe-action/u-swipe-action.vue +3 -3
- package/components/u-swipe-action-item/nvue - backup.js +3 -3
- package/components/u-swipe-action-item/nvue.js +3 -3
- package/components/u-swipe-action-item/u-swipe-action-item.vue +8 -5
- package/components/u-swiper/u-swiper.vue +35 -24
- package/components/u-swiper-indicator/u-swiper-indicator.vue +10 -7
- package/components/u-switch/u-switch.vue +15 -13
- package/components/u-tabbar/u-tabbar.vue +6 -5
- package/components/u-tabbar-item/u-tabbar-item.vue +7 -5
- package/components/u-table/u-table.vue +3 -3
- package/components/u-tabs/u-tabs.vue +18 -14
- package/components/u-tabs-item/u-tabs-item.vue +3 -3
- package/components/u-tag/props.js +2 -2
- package/components/u-tag/u-tag.vue +6 -4
- package/components/u-td/u-td.vue +3 -3
- package/components/u-text/u-text.vue +12 -10
- package/components/u-text/value.js +14 -12
- package/components/u-textarea/u-textarea.vue +11 -8
- package/components/u-toast/u-toast.vue +12 -9
- package/components/u-toolbar/u-toolbar.vue +3 -3
- package/components/u-tooltip/u-tooltip.vue +18 -17
- package/components/u-tr/u-tr.vue +3 -3
- package/components/u-transition/transition.js +2 -2
- package/components/u-transition/u-transition.vue +6 -5
- package/components/u-upload/mixin.js +4 -3
- package/components/u-upload/u-upload.vue +20 -17
- package/index.js +0 -5
- package/libs/function/index.js +27 -20
- package/libs/function/throttle.js +2 -2
- package/libs/mixin/mixin.js +14 -6
- package/libs/mixin/style.js +23 -4
- package/libs/util/route.js +6 -6
- package/package.json +1 -1
package/libs/mixin/mixin.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { deepMerge, $parent } from '../function/index';
|
|
2
|
+
import test from '../function/test';
|
|
3
|
+
import route from '../util/route';
|
|
1
4
|
export default {
|
|
2
5
|
// 定义每个组件都可能需要用到的外部样式以及类名
|
|
3
6
|
props: {
|
|
@@ -39,7 +42,7 @@ export default {
|
|
|
39
42
|
$u() {
|
|
40
43
|
// #ifndef APP-NVUE
|
|
41
44
|
// 在非nvue端,移除props,http,mixin等对象,避免在小程序setData时数据过大影响性能
|
|
42
|
-
return
|
|
45
|
+
return deepMerge(uni.$u, {
|
|
43
46
|
props: undefined,
|
|
44
47
|
http: undefined,
|
|
45
48
|
mixin: undefined
|
|
@@ -90,7 +93,7 @@ export default {
|
|
|
90
93
|
if (url) {
|
|
91
94
|
// h5官方回应:发行h5会自动摇树优化,所有使用uni的地方,都会被直接转换成具体的API调用 https://ask.dcloud.net.cn/question/161523?notification_id-1201922__rf-false__item_id-226372
|
|
92
95
|
// 使用封装的 route 进行跳转(直接调用方法),不使用 uni 对象
|
|
93
|
-
|
|
96
|
+
route({ type: this.linkType, url })
|
|
94
97
|
// 执行类似uni.navigateTo的方法
|
|
95
98
|
// uni[this.linkType]({
|
|
96
99
|
// url
|
|
@@ -122,7 +125,7 @@ export default {
|
|
|
122
125
|
// 将父组件this中对应的参数,赋值给本组件(u-radio的this)的parentData对象中对应的属性
|
|
123
126
|
// 之所以需要这么做,是因为所有端中,头条小程序不支持通过this.parent.xxx去监听父组件参数的变化
|
|
124
127
|
// 此处并不会自动更新子组件的数据,而是依赖父组件u-radio-group去监听data的变化,手动调用更新子组件的方法去重新获取
|
|
125
|
-
this.parent =
|
|
128
|
+
this.parent = $parent.call(this, parentName)
|
|
126
129
|
if (this.parent.children) {
|
|
127
130
|
// 如果父组件的children不存在本组件的实例,才将本实例添加到父组件的children中
|
|
128
131
|
this.parent.children.indexOf(this) === -1 && this.parent.children.push(this)
|
|
@@ -145,11 +148,16 @@ export default {
|
|
|
145
148
|
},
|
|
146
149
|
onReachBottom() {
|
|
147
150
|
uni.$emit('uOnReachBottom')
|
|
148
|
-
},
|
|
149
|
-
|
|
151
|
+
},
|
|
152
|
+
// #ifdef VUE2
|
|
153
|
+
beforeDestroy() {
|
|
154
|
+
// #endif
|
|
155
|
+
// #ifdef VUE3
|
|
156
|
+
beforeUnmount() {
|
|
157
|
+
// #endif
|
|
150
158
|
// 判断当前页面是否存在parent和chldren,一般在checkbox和checkbox-group父子联动的场景会有此情况
|
|
151
159
|
// 组件销毁时,移除子组件在父组件children数组中的实例,释放资源,避免数据混乱
|
|
152
|
-
if (this.parent &&
|
|
160
|
+
if (this.parent && test.array(this.parent.children)) {
|
|
153
161
|
// 组件销毁时,移除父组件中的children数组中对应的实例
|
|
154
162
|
const childrenList = this.parent.children
|
|
155
163
|
childrenList.map((child, index) => {
|
package/libs/mixin/style.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { addStyle, deepMerge, addUnit, trim } from '../function/index';
|
|
1
2
|
export default {
|
|
2
3
|
props: {
|
|
3
4
|
// flex排列方式
|
|
@@ -213,16 +214,34 @@ export default {
|
|
|
213
214
|
computed: {
|
|
214
215
|
viewStyle() {
|
|
215
216
|
const style = {}
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
const addStyleTmp = addStyle(this.width || this.w)
|
|
218
|
+
&& (style.width = addStyle(this.width || this.w))(this.height || this.h)
|
|
219
|
+
&& (style.height = addStyle(this.height || this.h))(this.margin || this.m)
|
|
220
|
+
&& (style.margin = addStyle(this.margin || this.m))(this.marginTop || this.mt)
|
|
221
|
+
&& (style.marginTop = addStyle(this.marginTop || this.mt))(this.marginRight || this.mr)
|
|
222
|
+
&& (style.marginRight = addStyle(this.marginRight || this.mr))(this.marginBottom || this.mb)
|
|
223
|
+
&& (style.marginBottom = addStyle(this.marginBottom || this.mb))(this.marginLeft || this.ml)
|
|
224
|
+
&& (style.marginLeft = addStyle(this.marginLeft || this.ml))(this.padding || this.p)
|
|
225
|
+
&& (style.padding = addStyle(this.padding || this.p))(this.paddingTop || this.pt)
|
|
226
|
+
&& (style.paddingTop = addStyle(this.paddingTop || this.pt))(this.paddingRight || this.pr)
|
|
227
|
+
&& (style.paddingRight = addStyle(this.paddingRight || this.pr))(this.paddingBottom || this.pb)
|
|
228
|
+
&& (style.paddingBottom = addStyle(this.paddingBottom || this.pb))(this.paddingLeft || this.pl)
|
|
229
|
+
&& (style.paddingLeft = addStyle(this.paddingLeft || this.pl))(this.color || this.c)
|
|
230
|
+
&& (style.color = this.color || this.c)(this.fontSize || this.fs)
|
|
231
|
+
&& (style.fontSize = this.fontSize || this.fs)(this.borderRadius || this.radius)
|
|
232
|
+
&& (style.borderRadius = this.borderRadius || this.radius)(this.position || this.pos)
|
|
233
|
+
&& (this.position = this.position || this.pos)(this.flexDirection || this.fd)
|
|
234
|
+
&& (this.flexDirection = this.flexDirection || this.fd)(this.justifyContent || jc)
|
|
235
|
+
&& (this.justifyContent = this.justifyContent || jc)(this.alignItems || ai)
|
|
236
|
+
&& (this.alignItems = this.alignItems || ai)
|
|
237
|
+
return deepMerge(style, addStyleTmp(this.customStyle))
|
|
219
238
|
}
|
|
220
239
|
},
|
|
221
240
|
methods: {
|
|
222
241
|
// 获取margin或者padding的单位,比如padding: 0 20转为padding: 0 20px
|
|
223
242
|
getUnit(unit = '') {
|
|
224
243
|
// 取出两端空格,分隔成数组,再对数组的每个元素添加单位,最后再合并成字符串
|
|
225
|
-
return
|
|
244
|
+
return trim(unit).split(' ').map((item) => addUnit(item)).join(' ')
|
|
226
245
|
}
|
|
227
246
|
}
|
|
228
247
|
}
|
package/libs/util/route.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* 路由跳转方法,该方法相对于直接使用uni.xxx的好处是使用更加简单快捷
|
|
3
3
|
* 并且带有路由拦截功能
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
import { queryParams, deepMerge, page } from '../function/index';
|
|
6
6
|
class Router {
|
|
7
7
|
constructor() {
|
|
8
8
|
// 原始属性定义
|
|
@@ -34,12 +34,12 @@ class Router {
|
|
|
34
34
|
let query = ''
|
|
35
35
|
if (/.*\/.*\?.*=.*/.test(url)) {
|
|
36
36
|
// object对象转为get类型的参数
|
|
37
|
-
query =
|
|
37
|
+
query = queryParams(params, false)
|
|
38
38
|
// 因为已有get参数,所以后面拼接的参数需要带上"&"隔开
|
|
39
39
|
return url += `&${query}`
|
|
40
40
|
}
|
|
41
41
|
// 直接拼接参数,因为此处url中没有后面的query参数,也就没有"?/&"之类的符号
|
|
42
|
-
query =
|
|
42
|
+
query = queryParams(params)
|
|
43
43
|
return url += query
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -53,13 +53,13 @@ class Router {
|
|
|
53
53
|
mergeConfig.url = this.mixinParam(options, params)
|
|
54
54
|
mergeConfig.type = 'navigateTo'
|
|
55
55
|
} else {
|
|
56
|
-
mergeConfig =
|
|
56
|
+
mergeConfig = deepMerge(this.config, options)
|
|
57
57
|
// 否则正常使用mergeConfig中的url和params进行拼接
|
|
58
58
|
mergeConfig.url = this.mixinParam(options.url, options.params)
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// 如果本次跳转的路径和本页面路径一致,不执行跳转,防止用户快速点击跳转按钮,造成多次跳转同一个页面的问题
|
|
62
|
-
if (mergeConfig.url ===
|
|
62
|
+
if (mergeConfig.url === page()) return
|
|
63
63
|
|
|
64
64
|
if (params.intercept) {
|
|
65
65
|
this.config.intercept = params.intercept
|
|
@@ -67,7 +67,7 @@ class Router {
|
|
|
67
67
|
// params参数也带给拦截器
|
|
68
68
|
mergeConfig.params = params
|
|
69
69
|
// 合并内外部参数
|
|
70
|
-
mergeConfig =
|
|
70
|
+
mergeConfig = deepMerge(this.config, mergeConfig)
|
|
71
71
|
// 判断用户是否定义了拦截器
|
|
72
72
|
if (typeof uni.$u.routeIntercept === 'function') {
|
|
73
73
|
// 定一个promise,根据用户执行resolve(true)或者resolve(false)来决定是否进行路由跳转
|