Commit 90115526 by 李伟康

commit 修复

1 parent 72496606
......@@ -3,14 +3,17 @@
<template v-for="(item,index) in list">
<view
:class="['tab',{active:index == tabIndex}]"
:ref="`tab-${index}`"
:id="`tab-${index}`"
:key="index"
@click="tabClick(index)"
>
{{item.tabName}}
</view>
</template>
<view class="border" :style="borderLeft"></view>
<view
class="border"
:style="borderLeft"
></view>
</view>
</template>
......@@ -18,16 +21,18 @@
export default {
name: 'Tabs',
props: {
list: Array
list: Array,
},
data () {
return {
tabIndex: 0,
borderLeft: 'display: none;'
borderLeft: 'display: none;',
}
},
mounted () {
this.setBorderLeft()
setTimeout(() => {
this.setBorderLeft()
}, 300)
},
methods: {
tabClick (index) {
......@@ -35,12 +40,19 @@ export default {
this.$emit('tabclick', index)
this.setBorderLeft()
},
setBorderLeft(){
let {tabIndex} = this
this.borderLeft = `left:${this.$refs[`tab-${tabIndex}`][0].$el.offsetLeft}px;`
setTimeout(()=>{
this.borderLeft += `display:block;`
},100)
setBorderLeft () {
let { tabIndex } = this
const query = uni.createSelectorQuery().in(this)
query
.select(`#tab-${tabIndex}`)
.boundingClientRect((data) => {
console.log(data)
this.borderLeft = `left:${data.left}px;`
setTimeout(() => {
this.borderLeft += `display:block;`
}, 100)
}).exec()
}
}
}
......@@ -72,7 +84,7 @@ export default {
font-weight: 500;
color: #292d33;
}
.border{
.border {
width: 384rpx;
height: 80rpx;
border: 4rpx solid #292d33;
......@@ -80,8 +92,8 @@ export default {
position: absolute;
left: 0;
top: 0;
transition: all .15s;
transition: all 0.15s;
z-index: 3;
}
}
</style>
\ No newline at end of file
......@@ -175,7 +175,6 @@ export default {
width: 100%;
height: 100%;
z-index: -1;
opacity: 0;
left: 0;
top: 0;
display: none;
......@@ -183,7 +182,7 @@ export default {
.showView {
z-index: 2;
display: block;
animation: show-view 0.25s forwards;
animation: show-view 0.25s ;
}
.pen-box {
position: fixed;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!