123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <template>
- <div class="simple-search">
- <input
- type="text"
- :placeholder="placeholder"
- v-model="inputVal"
- @input="(e) => $emit('input', e.target.value)"
- @keyup.enter="$emit('search', inputVal)"
- />
- </div>
- </template>
- <script>
- export default {
- model: {
- prop: 'value',
- event: 'input',
- },
- props: {
- value: {
- type: String,
- default: '',
- },
- placeholder: {
- type: String,
- default: '',
- },
- },
- data() {
- return {
- inputVal: '',
- }
- },
- }
- </script>
- <style scoped lang="scss">
- @media screen and (min-width: 768px) {
- .simple-search {
- &::before {
- content: '';
- display: block;
- background: url(https://static.caimei365.com/www/authentic/h5/icon-search.png)
- no-repeat center;
- width: 30px;
- height: 30px;
- position: absolute;
- background-size: 26px;
- top: 50%;
- left: 6px;
- transform: translateY(-50%);
- z-index: 9;
- }
- input {
- position: relative;
- display: block;
- width: 560px;
- height: 40px;
- background: rgba(255, 255, 255, 0.39);
- border-radius: 4px;
- outline: none;
- font-size: 16px;
- line-height: 40px;
- border: 0;
- padding-left: 44px;
- box-sizing: border-box;
- color: #fff;
- }
- }
- }
- @media screen and (max-width: 768px) {
- .simple-search {
- width: 92vw;
- height: 9.6vw;
- box-shadow: 0px 0.4vw 1vw rgba(51, 51, 51, 0.08);
- padding-left: 9.6vw;
- padding-right: 1.6vw;
- left: 50%;
- top: 0;
- background-color: #fff;
- border-radius: 0.4vw;
- &::before {
- content: '';
- display: block;
- background: url(https://static.caimei365.com/www/authentic/h5/icon-search.png)
- no-repeat;
- width: 6.4vw;
- height: 6.4vw;
- position: absolute;
- background-size: 6.4vw;
- left: 1.6vw;
- top: 1.6vw;
- }
- input {
- display: block;
- width: 100%;
- height: 9.6vw;
- line-height: 9.6vw;
- outline: none;
- }
- }
- }
- </style>
|