重点代码部分:
/deep/ ::-webkit-scrollbar {
display: block;
width: 4px !important;
height: 1px !important;
overflow: auto !important;
background: transparent !important;
-webkit-appearance: auto !important;
}
有滚动条代码:
<template>
<view class="home">
<scroll-view scroll-x class="navscroll">
<view class="item" v-for="item in 10">国内</view>
</scroll-view>
</view>
</template>
<script setup>
</script>
<style lang="scss" scoped>
.navscroll{
height: 100rpx;
// background-color: #fa7f8fa;
background-color: #40a1fa;
white-space: nowrap;
.item{
font-size: 40rpx;
display: inline-block;
line-height: 100rpx;
padding: 0 30rpx;
}
}
</style>
隐藏滚动条代码:
<template>
<view class="home">
<scroll-view scroll-x class="navscroll">
<view class="item" v-for="item in 10">国内</view>
</scroll-view>
</view>
</template>
<script setup>
</script>
<style lang="scss" scoped>
.navscroll{
height: 100rpx;
// background-color: #fa7f8fa;
background-color: #40a1fa;
white-space: nowrap;
/deep/ ::-webkit-scrollbar {
display: block;
width: 4px !important;
height: 1px !important;
overflow: auto !important;
background: transparent !important;
-webkit-appearance: auto !important;
}
.item{
font-size: 40rpx;
display: inline-block;
line-height: 100rpx;
padding: 0 30rpx;
}
}
</style>