提交 8977cf4f 编写于 作者: 雪洛's avatar 雪洛

revert: 暂时将UniElement类型改回Element

上级 4c7d2727
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
return { return {
height: 0, height: 0,
is_open: this.open as boolean, is_open: this.open as boolean,
boxNode: null as UniElement | null, boxNode: null as Element | null,
contentNode: null as UniElement | null, contentNode: null as Element | null,
}; };
}, },
watch: { watch: {
...@@ -51,8 +51,8 @@ ...@@ -51,8 +51,8 @@
$dispatch(this, 'UniCollapse', 'init', this) $dispatch(this, 'UniCollapse', 'init', this)
}, },
mounted() { mounted() {
this.boxNode = this.$refs['boxRef'] as UniElement; this.boxNode = this.$refs['boxRef'] as Element;
this.contentNode = this.$refs['contentRef'] as UniElement; this.contentNode = this.$refs['contentRef'] as Element;
// this.openCollapse(this.open) // this.openCollapse(this.open)
}, },
methods: { methods: {
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
} }
}, },
methods: { methods: {
getElementByNotExistId() : UniElement | null { getElementByNotExistId() : Element | null {
return uni.getElementById('not-exist-id') return uni.getElementById('not-exist-id')
}, },
changePageHeadBackgroundColor() { changePageHeadBackgroundColor() {
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
} }
}, },
methods: { methods: {
getElementByNotExistId() : UniElement | null { getElementByNotExistId() : Element | null {
return uni.getElementById('not-exist-id') return uni.getElementById('not-exist-id')
}, },
changePageHeadBackgroundColor() { changePageHeadBackgroundColor() {
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
methods: { methods: {
changeZIndex(zIndex : number) { changeZIndex(zIndex : number) {
this.zIndex = 20; this.zIndex = 20;
(this.$refs['view'] as UniElement).style.setProperty('z-index', zIndex); (this.$refs['view'] as Element).style.setProperty('z-index', zIndex);
} }
} }
} }
......
...@@ -52,24 +52,24 @@ ...@@ -52,24 +52,24 @@
data() { data() {
return { return {
isTranstionWidthOrHeight: false, isTranstionWidthOrHeight: false,
widthOrHeight: null as UniElement | null, widthOrHeight: null as Element | null,
isTranstionChangeMargin: false, isTranstionChangeMargin: false,
styleMargin: null as UniElement | null, styleMargin: null as Element | null,
isTransitionStylePadding: false, isTransitionStylePadding: false,
stylePadding: null as UniElement | null, stylePadding: null as Element | null,
isTransitionstyleBackground: false, isTransitionstyleBackground: false,
styleBackground: null as UniElement | null, styleBackground: null as Element | null,
isTransitionStyleTransform: false, isTransitionStyleTransform: false,
styleTransform: null as UniElement | null, styleTransform: null as Element | null,
isTransitionstyleBorder: false, isTransitionstyleBorder: false,
styleBorder: null as UniElement | null, styleBorder: null as Element | null,
isTransitionstylePosition: false, isTransitionstylePosition: false,
stylePosition: null as UniElement | null, stylePosition: null as Element | null,
isSetTransition: false, isSetTransition: false,
isTransitionpropertystyleBackground: false, isTransitionpropertystyleBackground: false,
propertyStyleBackground: null as UniElement | null, propertyStyleBackground: null as Element | null,
isTransitionStyleTransformWithOrigin: false, isTransitionStyleTransformWithOrigin: false,
styleTransformWithOrigin: null as UniElement | null, styleTransformWithOrigin: null as Element | null,
} }
}, },
onReady() { onReady() {
......
...@@ -70,7 +70,7 @@ export default { ...@@ -70,7 +70,7 @@ export default {
}, },
methods: { methods: {
validateGeneralAttributes() { validateGeneralAttributes() {
const generalTarget = this.$refs['general-target'] as UniElement const generalTarget = this.$refs['general-target'] as Element
const generalId = generalTarget.getAttribute('id') const generalId = generalTarget.getAttribute('id')
if (generalId != this.generalId) { if (generalId != this.generalId) {
this.validateGeneralAttrText = '基础属性 id 验证失败' this.validateGeneralAttrText = '基础属性 id 验证失败'
...@@ -103,7 +103,7 @@ export default { ...@@ -103,7 +103,7 @@ export default {
this.validateGeneralAttrText = '基础属性验证成功' this.validateGeneralAttrText = '基础属性验证成功'
}, },
changeHeight(){ changeHeight(){
const generalTarget = this.$refs['general-target'] as UniElement const generalTarget = this.$refs['general-target'] as Element
this.changeHeightByRefText = '已通过 ref 修改高度' this.changeHeightByRefText = '已通过 ref 修改高度'
generalTarget.style.setProperty('height', '200px') generalTarget.style.setProperty('height', '200px')
} }
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
lastX: 0, lastX: 0,
lastY: 0, lastY: 0,
touchEvent: null as TouchEvent | null, touchEvent: null as TouchEvent | null,
icon: null as UniElement | null icon: null as Element | null
} }
}, },
onReady() { onReady() {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
data() { data() {
return { return {
times: 0, times: 0,
element: null as UniElement | null, element: null as Element | null,
isStart: false, isStart: false,
buttonValue: "开启图片旋转", buttonValue: "开启图片旋转",
onTransitionEndTriggr: false onTransitionEndTriggr: false
......
...@@ -255,11 +255,11 @@ ...@@ -255,11 +255,11 @@
this.onMaxLengthInputValue = event.detail.value this.onMaxLengthInputValue = event.detail.value
}, },
setCursor: function (cursor : number) { setCursor: function (cursor : number) {
(this.$refs['input'] as UniElement).focus(); (this.$refs['input'] as Element).focus();
this.cursor = cursor; this.cursor = cursor;
}, },
setSelection: function (selectionStart : number, selectionEnd : number) { setSelection: function (selectionStart : number, selectionEnd : number) {
(this.$refs['input2'] as UniElement).focus(); (this.$refs['input2'] as Element).focus();
this.selectionStart = selectionStart; this.selectionStart = selectionStart;
this.selectionEnd = selectionEnd; this.selectionEnd = selectionEnd;
}, },
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
item_change_size_enum(index : number) { this.scrollIntoView = "item---"+index }, item_change_size_enum(index : number) { this.scrollIntoView = "item---"+index },
//自动化测试例专用 //自动化测试例专用
check_scroll_height(): Boolean { check_scroll_height(): Boolean {
var listElement = this.$refs["listview"] as UniElement var listElement = this.$refs["listview"] as Element
console.log("check_scroll_height--"+listElement.scrollHeight) console.log("check_scroll_height--"+listElement.scrollHeight)
if(listElement.scrollHeight > 2000) { if(listElement.scrollHeight > 2000) {
return true return true
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
}, },
//自动化测试例专用 //自动化测试例专用
check_scroll_width(): Boolean { check_scroll_width(): Boolean {
var listElement = this.$refs["listview"] as UniElement var listElement = this.$refs["listview"] as Element
console.log("check_scroll_width"+listElement.scrollWidth) console.log("check_scroll_width"+listElement.scrollWidth)
if(listElement.scrollWidth > 2000) { if(listElement.scrollWidth > 2000) {
return true return true
......
...@@ -184,7 +184,7 @@ ...@@ -184,7 +184,7 @@
checkScrollHeight(): Boolean { checkScrollHeight(): Boolean {
var element = this.$refs["scrollViewY"] var element = this.$refs["scrollViewY"]
if(element != null) { if(element != null) {
var scrollHeight = (element as UniElement).scrollHeight var scrollHeight = (element as Element).scrollHeight
console.log("checkScrollHeight"+scrollHeight) console.log("checkScrollHeight"+scrollHeight)
if(scrollHeight > 1900) { if(scrollHeight > 1900) {
return true return true
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
checkScrollWidth(): Boolean { checkScrollWidth(): Boolean {
var element = this.$refs["scrollViewX"] var element = this.$refs["scrollViewX"]
if(element != null) { if(element != null) {
var scrollWidth = (element as UniElement).scrollWidth var scrollWidth = (element as Element).scrollWidth
console.log("checkScrollWidth---"+scrollWidth) console.log("checkScrollWidth---"+scrollWidth)
if(scrollWidth > 1900) { if(scrollWidth > 1900) {
return true return true
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
}, },
//用于自动化测试 //用于自动化测试
listViewScrollByY(y : number) { listViewScrollByY(y : number) {
const listview = this.$refs["list-view"] as UniElement const listview = this.$refs["list-view"] as Element
listview.scrollBy(0, y) listview.scrollBy(0, y)
}, },
gotoStickyHeader(id : string) { gotoStickyHeader(id : string) {
......
...@@ -158,11 +158,11 @@ ...@@ -158,11 +158,11 @@
{ {
name: 'element draw', name: 'element draw',
url: 'element-draw', url: 'element-draw',
api: ["UniElement.getDrawableContext"] api: ["Element.getDrawableContext"]
},{ },{
name: 'element截图', name: 'element截图',
url: 'element-takesnapshot', url: 'element-takesnapshot',
api: ["UniElement.takeSnapshot"] api: ["Element.takeSnapshot"]
}, },
{ {
name: 'node节点', name: 'node节点',
...@@ -522,10 +522,10 @@ ...@@ -522,10 +522,10 @@
}) })
}, },
showPop: function () { showPop: function () {
(this.$refs["pop"] as UniElement).style.setProperty("display", "flex") (this.$refs["pop"] as Element).style.setProperty("display", "flex")
}, },
hidePop: function () { hidePop: function () {
(this.$refs["pop"] as UniElement).style.setProperty("display", "none") (this.$refs["pop"] as Element).style.setProperty("display", "none")
}, },
stopClickPop: function (e : MouseEvent) { stopClickPop: function (e : MouseEvent) {
e.stopPropagation() //点击到pop的非灰色区域,拦截点击事件 e.stopPropagation() //点击到pop的非灰色区域,拦截点击事件
......
...@@ -70,7 +70,7 @@ export default { ...@@ -70,7 +70,7 @@ export default {
// 触发整个日历的点击事件,需要计算点击位置 // 触发整个日历的点击事件,需要计算点击位置
select (event: TouchEvent) { select (event: TouchEvent) {
const refs = this.$refs['draw-weeks'] as UniElement const refs = this.$refs['draw-weeks'] as Element
const rect = refs.getBoundingClientRect(); const rect = refs.getBoundingClientRect();
const dom_x = rect.left; // 元素左上角相对于视口的 X 坐标 const dom_x = rect.left; // 元素左上角相对于视口的 X 坐标
const dom_y = rect.top; // 元素左上角相对于视口的 Y 坐标 const dom_y = rect.top; // 元素左上角相对于视口的 Y 坐标
...@@ -144,7 +144,7 @@ export default { ...@@ -144,7 +144,7 @@ export default {
// 绘制日历顶部信息 // 绘制日历顶部信息
drawHeader () { drawHeader () {
const refs = this.$refs['draw-header'] as UniElement const refs = this.$refs['draw-header'] as Element
let ctx = refs.getDrawableContext() let ctx = refs.getDrawableContext()
if (ctx == null) return if (ctx == null) return
const date_header_map = ['一', '二', '三', '四', '五', '六', '日'] const date_header_map = ['一', '二', '三', '四', '五', '六', '日']
...@@ -172,7 +172,7 @@ export default { ...@@ -172,7 +172,7 @@ export default {
// 绘制日历主体 // 绘制日历主体
drawWeek (weeks: Array<Array<DateType>>, time: string) { drawWeek (weeks: Array<Array<DateType>>, time: string) {
const start_time = Date.now() const start_time = Date.now()
const refs = this.$refs['draw-weeks'] as UniElement const refs = this.$refs['draw-weeks'] as Element
let ctx = refs.getDrawableContext() let ctx = refs.getDrawableContext()
if (ctx == null) return if (ctx == null) return
const dom = refs.getBoundingClientRect() const dom = refs.getBoundingClientRect()
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
uni.$emit('tabchange', e.detail.scrollTop) uni.$emit('tabchange', e.detail.scrollTop)
}, },
scrollTop(top : number) { scrollTop(top : number) {
(this.$refs["listView"] as UniElement).scrollTop = top (this.$refs["listView"] as Element).scrollTop = top
} }
} }
} }
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
}, },
onReady() { onReady() {
this.setSelectedIndex(0) this.setSelectedIndex(0)
this.$tabViewHeight = (this.$refs["tabview"] as UniElement).getBoundingClientRect().height this.$tabViewHeight = (this.$refs["tabview"] as Element).getBoundingClientRect().height
}, },
onUnload() { onUnload() {
uni.$off('tabchange', this.onTabPageEvent) uni.$off('tabchange', this.onTabPageEvent)
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
export default { export default {
data() { data() {
return { return {
$elementMap: new Map<string, UniElement>(), $elementMap: new Map<string, Element>(),
x: 0 as number, x: 0 as number,
y: 0 as number, y: 0 as number,
// 飘走的卡片计数 // 飘走的卡片计数
...@@ -78,12 +78,12 @@ ...@@ -78,12 +78,12 @@
this.setElementStyle('card', 'margin-top', screenHeight * 0.15 - 30 * _index + 'px'); this.setElementStyle('card', 'margin-top', screenHeight * 0.15 - 30 * _index + 'px');
this.setElementStyle('card', 'transform', 'scale(' + (0.9 + 0.05 * _index) + ')') this.setElementStyle('card', 'transform', 'scale(' + (0.9 + 0.05 * _index) + ')')
}, },
// 工具方法,用于快速设置 UniElement 的 style // 工具方法,用于快速设置 Element 的 style
setElementStyle(refName : string, propertyName : string, propertyStyle : any) : void { setElementStyle(refName : string, propertyName : string, propertyStyle : any) : void {
const elementMap = this.$data['$elementMap'] as Map<string, UniElement> const elementMap = this.$data['$elementMap'] as Map<string, Element>
let element : UniElement | null = elementMap.get(refName) let element : Element | null = elementMap.get(refName)
if (element == null) { if (element == null) {
element = this.$refs[refName] as UniElement; element = this.$refs[refName] as Element;
elementMap.set(refName, element) elementMap.set(refName, element)
} else { } else {
// console.log('直接拿'); // console.log('直接拿');
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
lastY: 0, //上次 lastY: 0, //上次
lastY2: 0, // lastY2: 0, //
bAnimation: false, //是否动画 bAnimation: false, //是否动画
halfNode: null as UniElement | null, halfNode: null as Element | null,
scrollNode: null as UniElement | null scrollNode: null as Element | null
} }
}, },
methods: { methods: {
......
...@@ -79,21 +79,21 @@ ...@@ -79,21 +79,21 @@
} as SwiperViewItem } as SwiperViewItem
] as SwiperViewItem[], ] as SwiperViewItem[],
swiperIndex: -1, swiperIndex: -1,
$pageScrollView: null as null | UniElement, $pageScrollView: null as null | Element,
$headerHeight: 0, $headerHeight: 0,
$animationFinishIndex: 0, $animationFinishIndex: 0,
$tabScrollView: null as null | UniElement, $tabScrollView: null as null | Element,
$indicatorNode: null as null | UniElement, $indicatorNode: null as null | Element,
$swiperWidth: 0, $swiperWidth: 0,
$swiperTabsRect: [] as SwiperTabsItem[] $swiperTabsRect: [] as SwiperTabsItem[]
} }
}, },
onReady() { onReady() {
this.$pageScrollView = this.$refs['pageScrollView'] as UniElement; this.$pageScrollView = this.$refs['pageScrollView'] as Element;
this.$headerHeight = (this.$refs['header'] as UniElement).offsetHeight this.$headerHeight = (this.$refs['header'] as Element).offsetHeight
this.$swiperWidth = (this.$refs['swiper'] as UniElement).getBoundingClientRect().width this.$swiperWidth = (this.$refs['swiper'] as Element).getBoundingClientRect().width
this.$tabScrollView = this.$refs['tabScroll'] as UniElement this.$tabScrollView = this.$refs['tabScroll'] as Element
this.$indicatorNode = this.$refs['indicator'] as UniElement this.$indicatorNode = this.$refs['indicator'] as Element
this.cacheTabItemsSize() this.cacheTabItemsSize()
this.setSwiperIndex(0, true) this.setSwiperIndex(0, true)
}, },
...@@ -173,7 +173,7 @@ ...@@ -173,7 +173,7 @@
}, },
cacheTabItemsSize() { cacheTabItemsSize() {
this.$swiperTabsRect.length = 0 this.$swiperTabsRect.length = 0
const tabs = this.$refs["swipertab"] as UniElement[] const tabs = this.$refs["swipertab"] as Element[]
tabs.forEach((node) => { tabs.forEach((node) => {
this.$swiperTabsRect.push({ this.$swiperTabsRect.push({
x: node.offsetLeft, x: node.offsetLeft,
......
...@@ -89,22 +89,22 @@ ...@@ -89,22 +89,22 @@
} as SwiperViewItem } as SwiperViewItem
] as SwiperViewItem[], ] as SwiperViewItem[],
swiperIndex: -1, swiperIndex: -1,
$pageScrollView: null as null | UniElement, $pageScrollView: null as null | Element,
$headerHeight: 0, $headerHeight: 0,
$animationFinishIndex: 0, $animationFinishIndex: 0,
$tabScrollView: null as null | UniElement, $tabScrollView: null as null | Element,
$indicatorNode: null as null | UniElement, $indicatorNode: null as null | Element,
$swiperWidth: 0, $swiperWidth: 0,
$swiperTabsRect: [] as SwiperTabsItem[], $swiperTabsRect: [] as SwiperTabsItem[],
nestedScrollChildId: "" nestedScrollChildId: ""
} }
}, },
onReady() { onReady() {
this.$pageScrollView = this.$refs['pageScrollView'] as UniElement; this.$pageScrollView = this.$refs['pageScrollView'] as Element;
this.$headerHeight = (this.$refs['header'] as UniElement).offsetHeight this.$headerHeight = (this.$refs['header'] as Element).offsetHeight
this.$swiperWidth = (this.$refs['swiper'] as UniElement).getBoundingClientRect().width this.$swiperWidth = (this.$refs['swiper'] as Element).getBoundingClientRect().width
this.$tabScrollView = this.$refs['tabScroll'] as UniElement this.$tabScrollView = this.$refs['tabScroll'] as Element
this.$indicatorNode = this.$refs['indicator'] as UniElement this.$indicatorNode = this.$refs['indicator'] as Element
this.cacheTabItemsSize() this.cacheTabItemsSize()
this.setSwiperIndex(0, true) this.setSwiperIndex(0, true)
}, },
...@@ -176,7 +176,7 @@ ...@@ -176,7 +176,7 @@
}, },
cacheTabItemsSize() { cacheTabItemsSize() {
this.$swiperTabsRect.length = 0 this.$swiperTabsRect.length = 0
const tabs = this.$refs["swipertab"] as UniElement[] const tabs = this.$refs["swipertab"] as Element[]
tabs.forEach((node) => { tabs.forEach((node) => {
this.$swiperTabsRect.push({ this.$swiperTabsRect.push({
x: node.offsetLeft, x: node.offsetLeft,
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
export default { export default {
data() { data() {
return { return {
$elementMap: new Map<string, UniElement>() $elementMap: new Map<string, Element>()
} }
}, },
methods: { methods: {
...@@ -60,12 +60,12 @@ ...@@ -60,12 +60,12 @@
this.setElementStyle("head-img-1", 'transform', `scale(${pullingDistance / 200 + 1})`) this.setElementStyle("head-img-1", 'transform', `scale(${pullingDistance / 200 + 1})`)
this.setElementStyle("head-img-2", 'transform', `scale(${pullingDistance / 200 + 1})`) this.setElementStyle("head-img-2", 'transform', `scale(${pullingDistance / 200 + 1})`)
}, },
// 工具方法,用于快速设置 UniElement 的 style // 工具方法,用于快速设置 Element 的 style
setElementStyle(refName : string, propertyName : string, propertyStyle : any) : void { setElementStyle(refName : string, propertyName : string, propertyStyle : any) : void {
let element : UniElement | null = (this.$data['$elementMap'] as Map<string, UniElement>).get(refName) let element : Element | null = (this.$data['$elementMap'] as Map<string, Element>).get(refName)
if (element == null) { if (element == null) {
element = this.$refs[refName] as UniElement; element = this.$refs[refName] as Element;
(this.$data['$elementMap'] as Map<string, UniElement>).set(refName, element) (this.$data['$elementMap'] as Map<string, Element>).set(refName, element)
} }
element.style.setProperty(propertyName, propertyStyle); element.style.setProperty(propertyName, propertyStyle);
}, },
......
...@@ -41,17 +41,17 @@ ...@@ -41,17 +41,17 @@
statusBarHeight: 35, statusBarHeight: 35,
scrollTop: 0, scrollTop: 0,
searchWidth: 700, searchWidth: 700,
searchNode: null as UniElement | null, searchNode: null as Element | null,
boxNode: null as UniElement | null, boxNode: null as Element | null,
navNode: null as UniElement | null navNode: null as Element | null
} }
}, },
onLoad() { }, onLoad() { },
onReady() { onReady() {
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight ?? 35; this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight ?? 35;
this.searchNode = this.$refs['search'] as UniElement; this.searchNode = this.$refs['search'] as Element;
this.boxNode = this.$refs['top-box'] as UniElement; this.boxNode = this.$refs['top-box'] as Element;
this.navNode = this.$refs['scroll-fold-nav'] as UniElement; this.navNode = this.$refs['scroll-fold-nav'] as Element;
}, },
methods: { methods: {
onScroll(e : ScrollEvent) { onScroll(e : ScrollEvent) {
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
stickyTop: 0, stickyTop: 0,
stickyTran: 0, stickyTran: 0,
scrollTop: 0, scrollTop: 0,
stickyNode: null as UniElement | null stickyNode: null as Element | null
} }
}, },
methods: { methods: {
...@@ -67,11 +67,11 @@ ...@@ -67,11 +67,11 @@
onLoad() { onLoad() {
}, },
onReady() { onReady() {
this.stickyNode = this.$refs['sticky'] as UniElement; this.stickyNode = this.$refs['sticky'] as Element;
// let rect = this.stickyNode?.getBoundingClientRect(); // let rect = this.stickyNode?.getBoundingClientRect();
// this.stickyTop = rect?.top; // this.stickyTop = rect?.top;
//this.stickyTop = this.stickyNode?.getBoundingClientRect()?.top; //this.stickyTop = this.stickyNode?.getBoundingClientRect()?.top;
let rect = (this.$refs['sticky'] as UniElement).getBoundingClientRect(); let rect = (this.$refs['sticky'] as Element).getBoundingClientRect();
this.stickyTop = rect.top; this.stickyTop = rect.top;
} }
} }
......
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
return { return {
swiperList: [] as SwiperViewItem[], swiperList: [] as SwiperViewItem[],
swiperIndex: -1, swiperIndex: -1,
$tabScrollView: null as null | UniElement, $tabScrollView: null as null | Element,
$indicatorNode: null as null | UniElement, $indicatorNode: null as null | Element,
$animationFinishIndex: 0, $animationFinishIndex: 0,
$swiperWidth: 0, $swiperWidth: 0,
$swiperTabsRect: [] as SwiperTabsItem[] $swiperTabsRect: [] as SwiperTabsItem[]
...@@ -63,9 +63,9 @@ ...@@ -63,9 +63,9 @@
} }
}, },
onReady() { onReady() {
this.$tabScrollView = this.$refs['tabScroll'] as UniElement this.$tabScrollView = this.$refs['tabScroll'] as Element
this.$indicatorNode = this.$refs['indicator'] as UniElement this.$indicatorNode = this.$refs['indicator'] as Element
this.$swiperWidth = (this.$refs["swiper"] as UniElement).getBoundingClientRect().width this.$swiperWidth = (this.$refs["swiper"] as Element).getBoundingClientRect().width
this.cacheTabItemsSize() this.cacheTabItemsSize()
this.setSwiperIndex(0, true) this.setSwiperIndex(0, true)
}, },
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
*/ */
cacheTabItemsSize() { cacheTabItemsSize() {
this.$swiperTabsRect.length = 0; this.$swiperTabsRect.length = 0;
const tabs = this.$refs["swipertab"] as UniElement[] const tabs = this.$refs["swipertab"] as Element[]
tabs.forEach((node) => { tabs.forEach((node) => {
this.$swiperTabsRect.push({ this.$swiperTabsRect.push({
x: node.offsetLeft, x: node.offsetLeft,
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
return { return {
swiperList: [] as SwiperViewItem[], swiperList: [] as SwiperViewItem[],
swiperIndex: -1, swiperIndex: -1,
$tabScrollView: null as null | UniElement, $tabScrollView: null as null | Element,
$animationFinishIndex: 0, $animationFinishIndex: 0,
$swiperWidth: 0 $swiperWidth: 0
} }
...@@ -53,8 +53,8 @@ ...@@ -53,8 +53,8 @@
} }
}, },
onReady() { onReady() {
this.$tabScrollView = this.$refs['tabScroll'] as UniElement this.$tabScrollView = this.$refs['tabScroll'] as Element
this.$swiperWidth = (this.$refs["swiper"] as UniElement).getBoundingClientRect().width this.$swiperWidth = (this.$refs["swiper"] as Element).getBoundingClientRect().width
this.setSwiperIndex(0, true) this.setSwiperIndex(0, true)
}, },
methods: { methods: {
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
const min_ratio = 1 const min_ratio = 1
const max_ratio = 1.3 const max_ratio = 1.3
const tabs = this.$refs['swipertab'] as UniElement[] const tabs = this.$refs['swipertab'] as Element[]
const current_node = tabs[current_index]! const current_node = tabs[current_index]!
const move_to_node = tabs[move_to_index]! const move_to_node = tabs[move_to_index]!
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册