1 <scroll-view scroll-x="true" :scroll-left="scrollLeft" class="head"> 2 <div @click="changeTab(index,item.id)" :class="[nowIndex==index ?'active':'']" v-for="(item, index) in navData" :key="index"> 3 {{item.name}} 4 </div> 5 </scroll-view> 6 //对子元素设置浮动都没用,父元素使用flex布局也是不行的 7 //需要如下设置 8 //父元素 9 .head{ 10 white-space: nowrap; 11 } 12 //子元素如下设置,这样设置后就可以横向滚动了 13 .item{ 14 display: inline-block; 15 }