老师帮我看看这个购物车上面那个图标能不能向左偏点

老师帮我看看这个购物车上面那个图标能不能向左偏点

<!--miniprogram/custom-tab-bar/index.wxml-->

<cover-view class="tab-bar">

<cover-view class="tab-bar-border"></cover-view>

<cover-view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">

<cover-image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></cover-image>

<cover-view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</cover-view>

</cover-view>

</cover-view>


/* custom-tab-bar/index.wxss */

.tab-bar {

position: fixed;

bottom: 0;

left: 0;

right: 0;

height: 50px;

background: white;

display: flex;

padding-bottom: env(safe-area-inset-bottom);

}

.tab-bar-border {

background-color: rgba(212, 212, 212, 0.8);

position: absolute;

left: 0;

top: 0;

width: 100%;

height: 1px;

transform: scaleY(0.5);

box-shadow: 0 1px 1px 0px rgba(212,212,212,0.40);

}

.tab-bar-item {

flex: 1;

text-align: center;

display: flex;

justify-content: center;

align-items: center;

flex-direction: column;

box-shadow: 0 -1px 1px 0 rgba(212,212,212,0.50);

}


.tab-bar-item cover-image {

width: 31px;

height: 24px;

margin-top: 7px;

}

.tab-bar-item cover-view {

font-size: 10px;

display: inline-block;

width: 31px;

height: 14px;

line-height: 14px;

text-align: center;

margin-top: 4px;

}


Component({

data: {

selected: 0,

color: "#9c9c9c",

selectedColor: "#ff0000",

list: [

{

pagePath: "/pages/index/index",

iconPath: "/image/首页1.png",

selectedIconPath: "/image/首页.png",

text: "首页"

},

{

pagePath: "/pages/shop/shop",

iconPath: "/image/购物车.png",

selectedIconPath: "/image/购物车1.png",

text: "购物车"

},

{

pagePath: "/pages/my/my",

iconPath: "/image/我的.png",

selectedIconPath: "/image/我的1.png",

text: "我的"

}

]

},

attached() { },

methods: {

switchTab(e) {

const data = e.currentTarget.dataset

const url = data.path

wx.switchTab({

url

})

this.setData({

selected: data.index

})

}

}

})


我实现的是这样子的

http://img1.sycdn.imooc.com//climg/5df49d1909021f3804810065.jpg


实际上需要这样的

http://img1.sycdn.imooc.com//climg/5df49d38096eb9e107120095.jpg

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

3回答
好帮手慕言 2019-12-15 10:33:57

同学你好,因为同学使用的是flex布局,设置居中之后,元素就是居中的,不用再做其他调整。如果同学就想调整一下第二个图标的位置,可以使用cover-view:nth-child(3) cover-image{}这个选择器调整。

如果还有其他疑问,建议在问答区重新提问,便于后期查找总结

如果我的回答帮到了你,欢迎采纳,祝学习愉快~

好帮手慕码 2019-12-14 19:02:03

同学你好,老师测试了同学的代码,效果是正常的。(图片没有和同学一样的,使用了其他图片)。如下:

http://img1.sycdn.imooc.com//climg/5df4b8ea09c7ab1603700075.jpg

有可能是图片的问题,同学可以使用边距稍微调试一下。

如果我的回答帮到了你,欢迎采纳,祝学习愉快~

  • 提问者 慕数据1344648 #1
    就是我想调一下第二个那个购物车往左边一点点,但是这个是循环出来的,我一调它就都调了如何就是只调第二个那个购物车那个图标。
    2019-12-14 19:04:05
提问者 慕数据1344648 2019-12-14 16:29:34

请老师帮忙看看


问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
3.WebAPP开发与小程序
  • 参与学习           人
  • 提交作业       622    份
  • 解答问题       6815    个

微信带火了小程序,也让前端工程师有了更多的展现机会,本阶段带你从移动基础知识的学习到webAPP开发,及小程序开发,让你PC端与移动端两端通吃。

了解课程
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师