123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- <template>
- <div class="tabbar">
- <div class="tab">
- <div
- class="item"
- :class="{ active: current === item.id }"
- v-for="item in tabs"
- :key="item.id"
- v-text="item.name"
- @click="$emit('change', item)"
- ></div>
- </div>
- <div class="tab-search">
- <input
- type="text"
- class="control"
- placeholder="搜索名称"
- @keyup.enter="($event) => $emit('search', $event.target.value)"
- />
- </div>
- </div>
- </template>
- <script>
- export default {
- name: 'SimpleTabs',
- props: {
- tabs: {
- type: Array,
- default: () => [],
- },
- current: {
- type: Number,
- default: 0,
- },
- },
- }
- </script>
- <style scoped lang="scss">
- @media screen and (min-width: 768px) {
- .tabbar {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-right: 24px;
- .tab-search {
- position: relative;
- width: 430px;
- height: 40px;
- border: 1px solid #d8d8d8;
- border-radius: 4px;
- padding: 0 16px;
- padding-left: 46px;
- &::after {
- position: absolute;
- top: 4px;
- left: 8px;
- content: '';
- width: 30px;
- height: 30px;
- background: url(https://static.caimei365.com/www/authentic/h5/icon-search.png)
- no-repeat center;
- background-size: 30px;
- }
- .control {
- width: 100%;
- height: 36px;
- display: block;
- border: 0;
- outline: none;
- line-height: 36px;
- background: #fff;
- }
- }
- .tab {
- overflow-x: auto;
- white-space: nowrap;
- height: 64px;
- &::-webkit-scrollbar {
- display: none;
- }
- .item {
- position: relative;
- display: inline-block;
- font-size: 20px;
- line-height: 64px;
- color: #101010;
- padding: 0 32px;
- cursor: pointer;
- &::after {
- position: absolute;
- content: '';
- width: 40px;
- height: 2px;
- background-color: #fff;
- bottom: 0;
- left: 50%;
- transform: translateX(-50%);
- }
- &.active {
- color: #bc1724;
- &::after {
- background-color: #bc1724;
- }
- }
- }
- }
- }
- }
- @media screen and (max-width: 768px) {
- .tabbar {
- .tab-search {
- display: none;
- }
- .tab {
- overflow-x: auto;
- white-space: nowrap;
- padding-top: 4vw;
- &::-webkit-scrollbar {
- display: none;
- }
- .item {
- position: relative;
- display: inline-block;
- font-size: 4.2vw;
- line-height: 8vw;
- color: #101010;
- padding: 0 6vw;
- padding-bottom: 1.2vw;
- &::after {
- position: absolute;
- content: '';
- width: 8vw;
- height: 0.4vw;
- background-color: #fff;
- bottom: 0;
- left: 50%;
- transform: translateX(-50%);
- }
- &.active {
- font-size: 4.6vw;
- color: #bc1724;
- &::after {
- background-color: #bc1724;
- }
- }
- }
- }
- }
- }
- </style>
|