graceNvueSearch.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <view class="gui-search" :style="{height:height, backgroundColor:background,borderRadius:borderRadius}" @tap.stop="tapme">
  3. <text class="gui-search-icon grace-icons"
  4. :style="{color:iconColor, fontSize:iconFontSize, lineHeight:height, width:iconWidth}">&#xe604;</text>
  5. <input type="text" class="gui-search-input" :disabled="disabled" value="" :placeholder="placeholder" v-model="inputVal"
  6. :style="{height:inputHeight, lineHeight:inputHeight, fontSize:inputFontSize}"
  7. @input="inputting" @confirm="confirm" confirm-type="search" />
  8. <text class="gui-search-icon grace-icons" v-if="inputVal.length > 0" @tap.stop="clearKwd"
  9. :style="{color:iconColor, fontSize:iconFontSize, lineHeight:height, width:iconWidth}">&#xe632;</text>
  10. </view>
  11. </template>
  12. <script>
  13. export default{
  14. props:{
  15. height:{type:String, default:'60rpx'},
  16. background:{type:String, default:'#FFFFFF'},
  17. fontSize:{type:String, default:'28rpx'},
  18. iconWidth:{type:String, default:'60rpx'},
  19. iconColor:{type:String, default:'#A5A7B2'},
  20. iconFontSize:{type:String, default:'30rpx'},
  21. inputHeight:{type:String, default:'30rpx'},
  22. inputFontSize:{type:String, default:'26rpx'},
  23. placeholder:{type:String, default:'关键字'},
  24. kwd:{type:String, default:''},
  25. borderRadius:{type:String, default:'66rpx'},
  26. disabled:{type:Boolean, default:false}
  27. },
  28. data() {
  29. return {
  30. inputVal : ''
  31. }
  32. },
  33. created: function (){
  34. this.inputVal = this.kwd;
  35. },
  36. watch:{
  37. kwd : function(val){
  38. this.inputVal = val;
  39. }
  40. },
  41. methods:{
  42. clearKwd : function () {
  43. this.inputVal = '';
  44. this.$emit('clear', '');
  45. },
  46. inputting : function(e){
  47. this.$emit('inputting', e.detail.value);
  48. },
  49. confirm : function (e) {
  50. this.$emit('confirm', e.detail.value);
  51. },
  52. tapme : function () {
  53. this.$emit('tapme')
  54. }
  55. }
  56. }
  57. </script>
  58. <style scoped>
  59. .gui-search{border-radius:66rpx; padding:0 10rpx; flex-direction:row; flex-wrap:nowrap; align-items:center; overflow:hidden;}
  60. .gui-search-icon{text-align:center;}
  61. .gui-search-input{width:600rpx; margin:0 10rpx; flex:1; border-width:0; padding:0;}
  62. </style>