···
<template>
<view>
<view>
<uni-segmented-control :current="current" :values="items" style-type="button" active-color="#dd524d" @clickItem="onClickItem" />
</view>
<view class="uni-padding-wrap uni-common-mt">
<uni-segmented-control :current="current" :values="items" style-type="text" active-color="#007aff" @clickItem="onClickItem" />
</view>
<view style="padding: 0px 30px;margin-top: 30px;">
<uni-segmented-control :current="current" :values="items" style-type="button" active-color="#4cd964" @clickItem="onClickItem" />
</view>
<view>
<uni-segmented-control :current="current" :values="items" style-type="text" active-color="#4cd964" @clickItem="onClickItem" />
</view>
</view>
</template>
<script>
export default {
components: {},
data() {
return {
items: ['选项卡1', '选项卡2', '选项卡3'],
current: 0,
}
},
methods: {
onClickItem(e) {
if (this.current !== e.currentIndex) {
this.current = e.currentIndex
}
}
}
}
</script>
···
这样引入是可以的,是不是你自己的css属性影响了组件的样式
2 个回复
昭昭L - 开心就好
···
<template>
<view>
<view>
<uni-segmented-control :current="current" :values="items" style-type="button" active-color="#dd524d" @clickItem="onClickItem" />
</view>
<view class="uni-padding-wrap uni-common-mt">
<uni-segmented-control :current="current" :values="items" style-type="text" active-color="#007aff" @clickItem="onClickItem" />
</view>
<view style="padding: 0px 30px;margin-top: 30px;">
<uni-segmented-control :current="current" :values="items" style-type="button" active-color="#4cd964" @clickItem="onClickItem" />
</view>
<view>
<uni-segmented-control :current="current" :values="items" style-type="text" active-color="#4cd964" @clickItem="onClickItem" />
</view>
</template>
<script>
export default {
components: {},
data() {
return {
items: ['选项卡1', '选项卡2', '选项卡3'],
current: 0,
}
},
methods: {
onClickItem(e) {
if (this.current !== e.currentIndex) {
this.current = e.currentIndex
}
}
}
}
</script>
···
这样引入是可以的,是不是你自己的css属性影响了组件的样式
l***@163.com
源码在view标签和text标签都有设置下划线,nvue文件里使用uni-segmented-control会加载默认黑色的色值应用下划线到text标签上,vue文件里使用会加载正常的activeColor样式色值应用下划线到view标签上,我自己修改为统一应用到text标签上