123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <template>
- <view class="top-btn">
- <view @click="cut(item,index)" v-for="(item,index) in list" :key="index" class="top-btn-item">
- {{item}}
- <view v-if="index == active" class="top-btn-item-color">
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: "topBtn",
- props: {
- list: {
- type: Array,
- default: () => []
- },
- active: {
- type: Number,
- default: () => 0
- }
- },
- data() {
- return {
- };
- },
- methods: {
- cut(item, index) {
- this.$emit('update:active', index)
- this.$emit('click',item)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .top-btn {
- width: 100%;
- box-sizing: border-box;
- display: flex;
- border-bottom: 1px solid #f2f2f2;
- padding-bottom: 32rpx;
- background-color: #fff;
- padding: 32rpx 0;
- .top-btn-item {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- position: relative;
- .top-btn-item-color {
- width: 150rpx;
- height: 8rpx;
- border-radius: 4rpx;
- background-color: rgba(5, 204, 161, 1);
- position: absolute;
- left: 50%;
- transform: translate(-50%, 0);
- bottom: -20rpx;
- }
- }
- .top-btn-item:nth-child(1){
- border-right: 1px solid #f2f2f2 ;
- }
- }
- </style>
|