From a155e7f4014565b06ce80bd52be325887d580451 Mon Sep 17 00:00:00 2001 From: yanyilin Date: Sat, 20 Jan 2024 21:43:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4Element=E4=B8=BAUniElement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uni-collapse-item/uni-collapse-item.vue | 8 ++++---- pages/CSS/layout/z-index.uvue | 2 +- pages/CSS/transition/transition.uvue | 18 +++++++++--------- .../general-attribute/general-attribute.uvue | 2 +- pages/component/general-event/touch-event.uvue | 2 +- .../general-event/transition-event.uvue | 2 +- pages/component/list-view/list-view.uvue | 4 ++-- .../scroll-view/scroll-view-props.uvue | 4 ++-- .../sticky-section/sticky-section.uvue | 2 +- pages/tabBar/API.uvue | 4 ++-- pages/template/calendar/calendar.uvue | 6 +++--- .../custom-tab-bar/custom-tab-bar-tab1.uvue | 2 +- .../custom-tab-bar/custom-tab-bar.uvue | 2 +- pages/template/drop-card/card/card.uvue | 2 +- pages/template/long-list/long-list.uvue | 18 +++++++++--------- pages/template/long-list2/long-list2.uvue | 18 +++++++++--------- .../pull-zoom-image/pull-zoom-image.uvue | 2 +- .../scroll-fold-nav/scroll-fold-nav.uvue | 12 ++++++------ .../template/scroll-sticky/scroll-sticky.uvue | 8 ++++---- .../components/uni-loading/circle.uvue | 2 +- .../components/uni-loading/icon.uvue | 2 +- .../components/uni-loading/snow.uvue | 2 +- 22 files changed, 62 insertions(+), 62 deletions(-) diff --git a/components/uni-collapse-item/uni-collapse-item.vue b/components/uni-collapse-item/uni-collapse-item.vue index f8d5dce3..1dc58a3a 100644 --- a/components/uni-collapse-item/uni-collapse-item.vue +++ b/components/uni-collapse-item/uni-collapse-item.vue @@ -36,8 +36,8 @@ return { height: 0, is_open: this.open as boolean, - boxNode: null as Element | null, - contentNode: null as Element | null, + boxNode: null as UniElement | null, + contentNode: null as UniElement | null, }; }, watch: { @@ -52,8 +52,8 @@ $dispatch(this, 'UniCollapse', 'init', this) }, mounted() { - this.boxNode = this.$refs['boxRef'] as Element; - this.contentNode = this.$refs['contentRef'] as Element; + this.boxNode = this.$refs['boxRef'] as UniElement; + this.contentNode = this.$refs['contentRef'] as UniElement; // this.openCollapse(this.open) }, methods: { diff --git a/pages/CSS/layout/z-index.uvue b/pages/CSS/layout/z-index.uvue index af3857ee..64425e22 100644 --- a/pages/CSS/layout/z-index.uvue +++ b/pages/CSS/layout/z-index.uvue @@ -36,7 +36,7 @@ methods: { changeZIndex(zIndex : number) { this.zIndex = 20; - (this.$refs['view'] as Element).style.setProperty('z-index', zIndex); + (this.$refs['view'] as UniElement).style.setProperty('z-index', zIndex); } } } diff --git a/pages/CSS/transition/transition.uvue b/pages/CSS/transition/transition.uvue index a3e39671..f4943f3a 100644 --- a/pages/CSS/transition/transition.uvue +++ b/pages/CSS/transition/transition.uvue @@ -52,24 +52,24 @@ data() { return { isTranstionWidthOrHeight: false, - widthOrHeight: null as Element | null, + widthOrHeight: null as UniElement | null, isTranstionChangeMargin: false, - styleMargin: null as Element | null, + styleMargin: null as UniElement | null, isTransitionStylePadding: false, - stylePadding: null as Element | null, + stylePadding: null as UniElement | null, isTransitionstyleBackground: false, - styleBackground: null as Element | null, + styleBackground: null as UniElement | null, isTransitionStyleTransform: false, - styleTransform: null as Element | null, + styleTransform: null as UniElement | null, isTransitionstyleBorder: false, - styleBorder: null as Element | null, + styleBorder: null as UniElement | null, isTransitionstylePosition: false, - stylePosition: null as Element | null, + stylePosition: null as UniElement | null, isSetTransition: false, isTransitionpropertystyleBackground: false, - propertyStyleBackground: null as Element | null, + propertyStyleBackground: null as UniElement | null, isTransitionStyleTransformWithOrigin: false, - styleTransformWithOrigin: null as Element | null, + styleTransformWithOrigin: null as UniElement | null, } }, onReady() { diff --git a/pages/component/general-attribute/general-attribute.uvue b/pages/component/general-attribute/general-attribute.uvue index fcd84848..0d324e3e 100644 --- a/pages/component/general-attribute/general-attribute.uvue +++ b/pages/component/general-attribute/general-attribute.uvue @@ -103,7 +103,7 @@ export default { this.validateGeneralAttrText = '基础属性验证成功' }, changeHeight(){ - const generalTarget = this.$refs['general-target'] as Element + const generalTarget = this.$refs['general-target'] as UniElement this.changeHeightByRefText = '已通过 ref 修改高度' generalTarget.style.setProperty('height', '200px') } diff --git a/pages/component/general-event/touch-event.uvue b/pages/component/general-event/touch-event.uvue index 15adbafb..703d395f 100644 --- a/pages/component/general-event/touch-event.uvue +++ b/pages/component/general-event/touch-event.uvue @@ -30,7 +30,7 @@ lastX: 0, lastY: 0, touchEvent: null as TouchEvent | null, - icon: null as Element | null + icon: null as UniElement | null } }, onReady() { diff --git a/pages/component/general-event/transition-event.uvue b/pages/component/general-event/transition-event.uvue index f7e636fa..6684c253 100644 --- a/pages/component/general-event/transition-event.uvue +++ b/pages/component/general-event/transition-event.uvue @@ -15,7 +15,7 @@ data() { return { times: 0, - element: null as Element | null, + element: null as UniElement | null, isStart: false, buttonValue: "开启图片旋转", onTransitionEndTriggr: false diff --git a/pages/component/list-view/list-view.uvue b/pages/component/list-view/list-view.uvue index 16b33818..0ccf5def 100644 --- a/pages/component/list-view/list-view.uvue +++ b/pages/component/list-view/list-view.uvue @@ -108,7 +108,7 @@ item_change_size_enum(index : number) { this.scrollIntoView = "item---" + index }, //自动化测试例专用 check_scroll_height() : Boolean { - var listElement = this.$refs["listview"] as Element + var listElement = this.$refs["listview"] as UniElement console.log("check_scroll_height--" + listElement.scrollHeight) if (listElement.scrollHeight > 2000) { return true @@ -117,7 +117,7 @@ }, //自动化测试例专用 check_scroll_width() : Boolean { - var listElement = this.$refs["listview"] as Element + var listElement = this.$refs["listview"] as UniElement console.log("check_scroll_width" + listElement.scrollWidth) if (listElement.scrollWidth > 2000) { return true diff --git a/pages/component/scroll-view/scroll-view-props.uvue b/pages/component/scroll-view/scroll-view-props.uvue index 7a068423..4be7d495 100644 --- a/pages/component/scroll-view/scroll-view-props.uvue +++ b/pages/component/scroll-view/scroll-view-props.uvue @@ -180,7 +180,7 @@ checkScrollHeight() : Boolean { var element = this.$refs["scrollViewY"] if (element != null) { - var scrollHeight = (element as Element).scrollHeight + var scrollHeight = (element as UniElement).scrollHeight console.log("checkScrollHeight" + scrollHeight) if (scrollHeight > 1900) { return true @@ -192,7 +192,7 @@ checkScrollWidth() : Boolean { var element = this.$refs["scrollViewX"] if (element != null) { - var scrollWidth = (element as Element).scrollWidth + var scrollWidth = (element as UniElement).scrollWidth console.log("checkScrollWidth---" + scrollWidth) if (scrollWidth > 1900) { return true diff --git a/pages/component/sticky-section/sticky-section.uvue b/pages/component/sticky-section/sticky-section.uvue index 45da8b32..db52d027 100644 --- a/pages/component/sticky-section/sticky-section.uvue +++ b/pages/component/sticky-section/sticky-section.uvue @@ -37,7 +37,7 @@ }, //用于自动化测试 listViewScrollByY(y : number) { - const listview = this.$refs["list-view"] as Element + const listview = this.$refs["list-view"] as UniElement listview.scrollBy(0, y) }, gotoStickyHeader(id : string) { diff --git a/pages/tabBar/API.uvue b/pages/tabBar/API.uvue index af8717c8..8b9444c5 100644 --- a/pages/tabBar/API.uvue +++ b/pages/tabBar/API.uvue @@ -530,10 +530,10 @@ }) }, showPop: function () { - (this.$refs["pop"] as Element).style.setProperty("display", "flex") + (this.$refs["pop"] as UniElement).style.setProperty("display", "flex") }, hidePop: function () { - (this.$refs["pop"] as Element).style.setProperty("display", "none") + (this.$refs["pop"] as UniElement).style.setProperty("display", "none") }, stopClickPop: function (e : PointerEvent) { e.stopPropagation() //点击到pop的非灰色区域,拦截点击事件 diff --git a/pages/template/calendar/calendar.uvue b/pages/template/calendar/calendar.uvue index 1de734f0..6d8a37cc 100644 --- a/pages/template/calendar/calendar.uvue +++ b/pages/template/calendar/calendar.uvue @@ -70,7 +70,7 @@ export default { // 触发整个日历的点击事件,需要计算点击位置 select (event: TouchEvent) { - const refs = this.$refs['draw-weeks'] as Element + const refs = this.$refs['draw-weeks'] as UniElement const rect = refs.getBoundingClientRect(); const dom_x = rect.left; // 元素左上角相对于视口的 X 坐标 const dom_y = rect.top; // 元素左上角相对于视口的 Y 坐标 @@ -144,7 +144,7 @@ export default { // 绘制日历顶部信息 drawHeader () { - const refs = this.$refs['draw-header'] as Element + const refs = this.$refs['draw-header'] as UniElement let ctx = refs.getDrawableContext() if (ctx == null) return const date_header_map = ['一', '二', '三', '四', '五', '六', '日'] @@ -172,7 +172,7 @@ export default { // 绘制日历主体 drawWeek (weeks: Array>, time: string) { const start_time = Date.now() - const refs = this.$refs['draw-weeks'] as Element + const refs = this.$refs['draw-weeks'] as UniElement let ctx = refs.getDrawableContext() if (ctx == null) return const dom = refs.getBoundingClientRect() diff --git a/pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue b/pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue index 22807da0..c88a5d51 100644 --- a/pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue +++ b/pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue @@ -35,7 +35,7 @@ uni.$emit('tabchange', e.detail.scrollTop) }, scrollTop(top : number) { - (this.$refs["listView"] as Element).scrollTop = top + (this.$refs["listView"] as UniElement).scrollTop = top } } } diff --git a/pages/template/custom-tab-bar/custom-tab-bar.uvue b/pages/template/custom-tab-bar/custom-tab-bar.uvue index a847c4a8..c633bdc1 100644 --- a/pages/template/custom-tab-bar/custom-tab-bar.uvue +++ b/pages/template/custom-tab-bar/custom-tab-bar.uvue @@ -73,7 +73,7 @@ }, onReady() { this.setSelectedIndex(0) - this.tabViewHeight = (this.$refs["tabview"] as Element).getBoundingClientRect().height + this.tabViewHeight = (this.$refs["tabview"] as UniElement).getBoundingClientRect().height }, onUnload() { uni.$off('tabchange', this.onTabPageEvent) diff --git a/pages/template/drop-card/card/card.uvue b/pages/template/drop-card/card/card.uvue index 1909a4d3..18b5771d 100644 --- a/pages/template/drop-card/card/card.uvue +++ b/pages/template/drop-card/card/card.uvue @@ -83,7 +83,7 @@ const elementMap = this.$data['$elementMap'] as Map let element : Element | null = elementMap.get(refName) if (element == null) { - element = this.$refs[refName] as Element; + element = this.$refs[refName] as UniElement; elementMap.set(refName, element) } else { // console.log('直接拿'); diff --git a/pages/template/long-list/long-list.uvue b/pages/template/long-list/long-list.uvue index 38ceeb56..18f01110 100644 --- a/pages/template/long-list/long-list.uvue +++ b/pages/template/long-list/long-list.uvue @@ -79,21 +79,21 @@ } as SwiperViewItem ] as SwiperViewItem[], swiperIndex: -1, - $pageScrollView: null as null | Element, + $pageScrollView: null as null | UniElement, $headerHeight: 0, $animationFinishIndex: 0, - $tabScrollView: null as null | Element, - $indicatorNode: null as null | Element, + $tabScrollView: null as null | UniElement, + $indicatorNode: null as null | UniElement, $swiperWidth: 0, $swiperTabsRect: [] as SwiperTabsItem[] } }, onReady() { - this.$pageScrollView = this.$refs['pageScrollView'] as Element; - this.$headerHeight = (this.$refs['header'] as Element).offsetHeight - this.$swiperWidth = (this.$refs['swiper'] as Element).getBoundingClientRect().width - this.$tabScrollView = this.$refs['tabScroll'] as Element - this.$indicatorNode = this.$refs['indicator'] as Element + this.$pageScrollView = this.$refs['pageScrollView'] as UniElement; + this.$headerHeight = (this.$refs['header'] as UniElement).offsetHeight + this.$swiperWidth = (this.$refs['swiper'] as UniElement).getBoundingClientRect().width + this.$tabScrollView = this.$refs['tabScroll'] as UniElement + this.$indicatorNode = this.$refs['indicator'] as UniElement this.cacheTabItemsSize() this.setSwiperIndex(0, true) }, @@ -173,7 +173,7 @@ }, cacheTabItemsSize() { this.$swiperTabsRect.length = 0 - const tabs = this.$refs["swipertab"] as Element[] + const tabs = this.$refs["swipertab"] as UniElement[] tabs.forEach((node) => { this.$swiperTabsRect.push({ x: node.offsetLeft, diff --git a/pages/template/long-list2/long-list2.uvue b/pages/template/long-list2/long-list2.uvue index 762bf3bd..006007bf 100644 --- a/pages/template/long-list2/long-list2.uvue +++ b/pages/template/long-list2/long-list2.uvue @@ -89,22 +89,22 @@ } as SwiperViewItem ] as SwiperViewItem[], swiperIndex: -1, - $pageScrollView: null as null | Element, + $pageScrollView: null as null | UniElement, $headerHeight: 0, $animationFinishIndex: 0, - $tabScrollView: null as null | Element, - $indicatorNode: null as null | Element, + $tabScrollView: null as null | UniElement, + $indicatorNode: null as null | UniElement, $swiperWidth: 0, $swiperTabsRect: [] as SwiperTabsItem[], nestedScrollChildId: "" } }, onReady() { - this.$pageScrollView = this.$refs['pageScrollView'] as Element; - this.$headerHeight = (this.$refs['header'] as Element).offsetHeight - this.$swiperWidth = (this.$refs['swiper'] as Element).getBoundingClientRect().width - this.$tabScrollView = this.$refs['tabScroll'] as Element - this.$indicatorNode = this.$refs['indicator'] as Element + this.$pageScrollView = this.$refs['pageScrollView'] as UniElement; + this.$headerHeight = (this.$refs['header'] as UniElement).offsetHeight + this.$swiperWidth = (this.$refs['swiper'] as UniElement).getBoundingClientRect().width + this.$tabScrollView = this.$refs['tabScroll'] as UniElement + this.$indicatorNode = this.$refs['indicator'] as UniElement this.cacheTabItemsSize() this.setSwiperIndex(0, true) }, @@ -176,7 +176,7 @@ }, cacheTabItemsSize() { this.$swiperTabsRect.length = 0 - const tabs = this.$refs["swipertab"] as Element[] + const tabs = this.$refs["swipertab"] as UniElement[] tabs.forEach((node) => { this.$swiperTabsRect.push({ x: node.offsetLeft, diff --git a/pages/template/pull-zoom-image/pull-zoom-image.uvue b/pages/template/pull-zoom-image/pull-zoom-image.uvue index 6fe58d34..e789f37b 100644 --- a/pages/template/pull-zoom-image/pull-zoom-image.uvue +++ b/pages/template/pull-zoom-image/pull-zoom-image.uvue @@ -66,7 +66,7 @@ setElementStyle(refName : string, propertyName : string, propertyStyle : any) : void { let element : Element | null = (this.$data['$elementMap'] as Map).get(refName) if (element == null) { - element = this.$refs[refName] as Element; + element = this.$refs[refName] as UniElement; (this.$data['$elementMap'] as Map).set(refName, element) } element.style.setProperty(propertyName, propertyStyle); diff --git a/pages/template/scroll-fold-nav/scroll-fold-nav.uvue b/pages/template/scroll-fold-nav/scroll-fold-nav.uvue index 9538ac1c..e3d47315 100644 --- a/pages/template/scroll-fold-nav/scroll-fold-nav.uvue +++ b/pages/template/scroll-fold-nav/scroll-fold-nav.uvue @@ -49,17 +49,17 @@ statusBarHeight: 35, scrollTop: 0, searchWidth: 700, - searchNode: null as Element | null, - boxNode: null as Element | null, - navNode: null as Element | null + searchNode: null as UniElement | null, + boxNode: null as UniElement | null, + navNode: null as UniElement | null } }, onLoad() { }, onReady() { this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight ?? 35; - this.searchNode = this.$refs['search'] as Element; - this.boxNode = this.$refs['top-box'] as Element; - this.navNode = this.$refs['scroll-fold-nav'] as Element; + this.searchNode = this.$refs['search'] as UniElement; + this.boxNode = this.$refs['top-box'] as UniElement; + this.navNode = this.$refs['scroll-fold-nav'] as UniElement; }, methods: { onScroll(e : ScrollEvent) { diff --git a/pages/template/scroll-sticky/scroll-sticky.uvue b/pages/template/scroll-sticky/scroll-sticky.uvue index f09ff9b5..060a3283 100644 --- a/pages/template/scroll-sticky/scroll-sticky.uvue +++ b/pages/template/scroll-sticky/scroll-sticky.uvue @@ -34,7 +34,7 @@ stickyTop: 0, stickyTran: 0, scrollTop: 0, - stickyNode: null as Element | null + stickyNode: null as UniElement | null } }, methods: { @@ -67,12 +67,12 @@ onLoad() { }, onReady() { - this.stickyNode = this.$refs['sticky'] as Element; + this.stickyNode = this.$refs['sticky'] as UniElement; // let rect = this.stickyNode?.getBoundingClientRect(); // this.stickyTop = rect?.top; //this.stickyTop = this.stickyNode?.getBoundingClientRect()?.top; - const stickyRect = (this.$refs['sticky'] as Element).getBoundingClientRect(); - const scrollRect = (this.$refs['scroll'] as Element).getBoundingClientRect(); + const stickyRect = (this.$refs['sticky'] as UniElement).getBoundingClientRect(); + const scrollRect = (this.$refs['scroll'] as UniElement).getBoundingClientRect(); this.stickyTop = stickyRect.top - scrollRect.top; } } diff --git a/uni_modules/uni-loading/components/uni-loading/circle.uvue b/uni_modules/uni-loading/components/uni-loading/circle.uvue index b911892c..ced8f80d 100644 --- a/uni_modules/uni-loading/components/uni-loading/circle.uvue +++ b/uni_modules/uni-loading/components/uni-loading/circle.uvue @@ -56,7 +56,7 @@ * 初始化圆环 */ init() { - const refs = this.$refs[this.elId] as Element + const refs = this.$refs[this.elId] as UniElement let ctx = refs.getDrawableContext()! this.build_circular(ctx) }, diff --git a/uni_modules/uni-loading/components/uni-loading/icon.uvue b/uni_modules/uni-loading/components/uni-loading/icon.uvue index 8f8cce54..2c4435f0 100644 --- a/uni_modules/uni-loading/components/uni-loading/icon.uvue +++ b/uni_modules/uni-loading/components/uni-loading/icon.uvue @@ -23,7 +23,7 @@ const elId = `Uni_${(Math.random() * 10e5).toInt().toString(36)}` return { elId: elId, - element: null as Element | null, + element: null as UniElement | null, times: 0, aniStyle: '', deg: 3600000 diff --git a/uni_modules/uni-loading/components/uni-loading/snow.uvue b/uni_modules/uni-loading/components/uni-loading/snow.uvue index 0fead8d6..245efc09 100644 --- a/uni_modules/uni-loading/components/uni-loading/snow.uvue +++ b/uni_modules/uni-loading/components/uni-loading/snow.uvue @@ -27,7 +27,7 @@ }; }, mounted() { - const refs = this.$refs[this.elId] as Element + const refs = this.$refs[this.elId] as UniElement let ctx = refs.getDrawableContext()! this.spinner(ctx) }, -- GitLab