代码拉取完成,页面将自动刷新
同步操作将从 进击的皇虫/BookChatApp 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<template>
<view>
<form class='search' @click="focusSearch">
<input :focus='focus || clickFocus' :value='searchWd' :placeholder='placeholder' @input="change" @confirm="search" confirm-type="search"
name='wd' />
<image @click.stop='clear' v-if='showClear' class='clear' src='/static/images/clear.png'></image>
<image @click.stop='search' src='/static/images/search.png'></image>
</form>
</view>
</template>
<script>
export default {
name: "search",
data() {
return {
showClear: false,
searchWd: '',
clickFocus: false,
}
},
props: {
focus: {
type: Boolean
},
wd: {
type: String,
default: '',
},
target: {
type: String
},
placeholder: {
type: String,
default: 'Search...'
}
},
created() {
this.init()
},
methods: {
init() {
if (this.wd) this.showClear = true
this.searchWd = this.wd
},
clear(e) {
this.showClear = false
this.searchWd = ''
this.$emit('clear')
},
change(e) {
let wd = e.detail.value.trim()
this.showClear = wd ? true : false
this.searchWd = wd
},
search() {
if (this.target) {
uni.navigateTo({
url: this.target + "?wd=" + this.searchWd
})
} else {
this.$emit('search', {
wd: this.searchWd
})
}
},
focusSearch(){
this.clickFocus=true
}
},
watch: {
wd: function() {
this.init()
}
}
}
</script>
<style scoped>
form {
margin-top: 15px;
position: relative;
display: block;
background-color: #f8f8f8;
border-radius: 5px;
padding-right: 70px;
padding-top: 8px;
padding-left: 15px;
padding-bottom: 8px;
height: 40px;
box-sizing: border-box;
}
form input {
height: 24px;
line-height: 24px;
font-size: 15px;
min-height: 24px;
}
form image {
margin: 0;
position: absolute;
top: 0;
right: 0;
box-sizing: border-box;
height: 40px;
width: 40px;
padding: 8px 8px;
z-index: 99;
}
form image.clear {
right: 35px;
z-index: 88;
}
@media (min-width: 768px) {
form {
height: 50px;
border-radius: 5px;
padding-right: 70px;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 15px;
box-sizing: border-box;
}
form input {
font-size: 17px;
height: 30px;
line-height: 30px;
min-height: 30px;
}
form image {
height: 50px;
width: 50px;
padding: 10px 10px;
}
form image.clear {
right: 35px;
}
}
</style>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。