Commit 90115526 by 李伟康

commit 修复

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