12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <template>
- <view>
- <!-- 搜索 -->
- <view class="searchBox">
- <image src="../../static/mobile/icon_search@2x.png" class="searchImg"></image>
- <input type="text" class="searchInput" :placeholder='placeholder' v-model="inputValue"
- @confirm="search" />
- <image src="../../static/mobile/icon_close.png" class="searchClose" v-if="inputValue!=''"
- @click="clear"></image>
- </view>
- </view>
- </template>
- <script>
- export default {
- name: "searchBox",
- props: {
- placeholder: {
- type: String,
- default: '请输入搜索内容'
- },
-
- },
- data() {
- return {
- inputValue: '',
- };
- },
- methods:{
- search(){
- if (!this.inputValue) return;
- //console.log(this.inputValue);
- this.$emit('search',this.inputValue);
-
- },
- clear(){
- this.inputValue = ''
- this.$emit('search','');
- },
- }
- }
- </script>
- <style>
- .searchBox {
- height: 72rpx;
- margin: 24rpx 0;
- background-color: #FFFFFF;
- border-radius: 36rpx;
- border: #FF4F00 3rpx solid;
- display: flex;
- position: relative;
- }
- .searchImg {
- margin-top: 20rpx;
- margin-left: 20rpx;
- width: 32rpx;
- height: 32rpx;
- }
- .searchInput {
- height: 72rpx;
- font-size: 28rpx;
- padding-left: 16rpx;
- width: 78%;
- }
- .searchClose {
- position: absolute;
- width: 36rpx;
- height: 36rpx;
- right: 36rpx;
- top: 20rpx;
- }
- </style>
|