|
@@ -9,10 +9,17 @@ Component({
|
|
|
value: ['最新', '最热']
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
lifetimes: {
|
|
|
ready: function () {
|
|
|
- this.chengeSelect()
|
|
|
+ const that = this;
|
|
|
+ let query = wx.createSelectorQuery().in(this)
|
|
|
+ query.select('.switch-box').boundingClientRect();
|
|
|
+ query.exec(function (res) {
|
|
|
+ that.setData({
|
|
|
+ baseLeft: res[0].left
|
|
|
+ })
|
|
|
+ that.chengeSelect()
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -22,6 +29,7 @@ Component({
|
|
|
data: {
|
|
|
checkedItem: 0, //选中项
|
|
|
animationData: {}, //横线平移动画
|
|
|
+ baseLeft: 0,
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -44,7 +52,7 @@ Component({
|
|
|
let query = wx.createSelectorQuery().in(this)
|
|
|
query.select('.active').boundingClientRect();
|
|
|
query.exec(function (res) {
|
|
|
- animation.translate(res[0].left + 2).step({
|
|
|
+ animation.translate(res[0].left - that.data.baseLeft + 2).step({
|
|
|
duration: 300
|
|
|
})
|
|
|
that.setData({
|