搜索 重置 ._iconify-ep">
当前位置:   article > 正文

vue + element-ui 搜索组件封装_iconify-ep

iconify-ep

子组件:

<template>
  <div class="search_page">
    <el-input v-model="search"></el-input>
    <el-button type="primary" @click="searchHandle">搜索</el-button>
    <el-button @click="resetHandle">重置</el-button>
  </div>
</template>
<script>
export default {
  data () {
    return {
      search: ''
    }
  },
  methods: {
    searchHandle() {
      this.$emit('searchHandle', this.search) 
    },
    resetHandle() {
      this.search = ''
      this.$emit('searchHandle', this.search)  
    }
  }
}
</script>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

父组件调用:

<template>
	<Search @searchHandle="searchHandle($event)"></Search>
</template>

<script>
import Search from '@/components/Search '
export default {
	components: {
		Search
	},
	methods: {
		searchHandle (event) {
			// 请求接口,执行搜索 参数event
		}
	}
}
</script>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/秋刀鱼在做梦/article/detail/803646
推荐阅读
相关标签
  

闽ICP备14008679号