欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Vue2.x通用條件搜索組件的封裝及應(yīng)用詳解

 更新時(shí)間:2019年05月28日 10:45:14   作者:ECMAScripter  
這篇文章主要為大家詳細(xì)介紹了Vue2.x通用條件搜索組件的封裝及應(yīng)用,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Vue2.x通用條件搜索組件的封裝及應(yīng)用,供大家參考,具體內(nèi)容如下

效果

 

組件源碼

<template>
 <div class="search">
 <el-select v-model="type" @change="changeType" class="select">
  <el-option
  v-for="item in selectItems"
  :key="item.value"
  :lable="item.label"
  :value="item.value">
  </el-option>
 </el-select>
 <div class='search-input'>
  <el-input :placeholder="placeholderDes" v-model="searchValue"></el-input>
 </div>
 <el-button icon="el-icon-search" @click="search"></el-button>
 </div>
</template>

<script>
export default {
 data () {
 return {
  searchValue: '',
  type: ''
 }
 },
 created () {
 this.type = this.initType
 },
 props: {
 selectItems: {
  type: Array,
  require: true
 },
 placeholderDes: {
  type: String,
  require: true
 },
 initType: {
  type: String,
  require: true
 }
 },
 methods: {
 changeType (newType) {
  this.$emit('changeType', newType)
 },
 search () {
  this.$emit('searchOk', this.searchValue)
 }
 }
}
</script>

<style lang="less" scoped>
.search {
 display: flex;
 .el-select {
 width: 90px;
 height: 40px;
 box-sizing: border-box;
 border-right: none;
 border-radius: 0;
 background-color: #DDF0FE;
 border: 1px solid #40b0ff;
 }
 .search-input {
 width: 216px;
 height: 40px;
 border: 1px solid #40b0ff;
 border-left: none;
 box-sizing: border-box;
 font-family: 'MicrosoftYaHei';
 font-size: 14px;
 color: #909399;
 border-radius: 0;
 }
 .el-button {
 width: 44px;
 height: 40px;
 padding: 0;
 border: 1px solid #40b0ff;
 border-radius: 0;
 color: #fff;
 background: #40b0ff;
 &:hover {
  background: #10b0ff
 }
 }
}
</style>

父組件中的引用

<template>
 <div class="test">
 <v-search :initType="initType" :selectItems="selectItems" :placeholderDes="placeholderDes" @changeType="changeType" @searchOk="searchOk"></v-search>
 </div>
</template>

<script>
import VSearch from '@/components/Common/ZLGComponents/XGQTest/Search/Search'
export default {
 data () {
 return {
  selectItems: [],
  selectStatus: 'devname',
  initType: '',
  placeholderDes: '請(qǐng)輸入要搜索的測(cè)試名稱(chēng)'
 }
 },
 created () {
 this.setSelectItems()
 this.setInitType()
 },
 methods: {
 setSelectItems () {
  this.selectItems = [{
  value: '測(cè)試名',
  label: '測(cè)試名'
  }, {
  value: '測(cè)試ID',
  label: '測(cè)試ID'
  }]
 },
 changeType (newType) {
  if (newType === '測(cè)試名') {
  this.placeholderDes = '請(qǐng)輸入要搜索的測(cè)試名稱(chēng)'
  this.selectStatus = 'name'
  } else if (newType === '測(cè)試ID') {
  this.placeholderDes = '請(qǐng)輸入要搜索的測(cè)試ID'
  this.selectStatus = 'id'
  }
 },
 searchOk (value) {
  console.log(this.selectStatus)
  console.log(value)
  // 調(diào)用你的搜索接口,搜索條件為搜索的類(lèi)型 + 搜索值
  // yourSearch (this.selectStatus, value)
 },
 setInitType () {
  this.initType = '測(cè)試名'
 }
 },
 components: {
 VSearch
 }
}
</script>

<style lang="less" scoped>
</style>

組件基于element-UI的二次封裝,適合用于使用element的項(xiàng)目,子組件父組件demo完整源碼如上所示,有疑問(wèn)建議研究一下源碼,也歡迎留言交流。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue-router之nuxt動(dòng)態(tài)路由設(shè)置的兩種方法小結(jié)

    vue-router之nuxt動(dòng)態(tài)路由設(shè)置的兩種方法小結(jié)

    今天小編就為大家分享一篇vue-router之nuxt動(dòng)態(tài)路由設(shè)置的兩種方法小結(jié),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-09-09
  • vue制作toast組件npm包示例代碼

    vue制作toast組件npm包示例代碼

    這篇文章主要介紹了vue制作一個(gè)toast組件npm包,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-10-10
  • 詳解vue?route介紹、基本使用、嵌套路由

    詳解vue?route介紹、基本使用、嵌套路由

    vue-router是Vue.js官方的路由插件,它和vue.js是深度集成的,適合用于構(gòu)建單頁(yè)面應(yīng)用,這篇文章主要介紹了vue?route介紹、基本使用、嵌套路由,需要的朋友可以參考下
    2022-08-08
  • 如何解決this.$refs.form.validate()不執(zhí)行的問(wèn)題

    如何解決this.$refs.form.validate()不執(zhí)行的問(wèn)題

    這篇文章主要介紹了如何解決this.$refs.form.validate()不執(zhí)行的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-09-09
  • 從0搭建Vue3組件庫(kù)如何使用?glup?打包組件庫(kù)并實(shí)現(xiàn)按需加載

    從0搭建Vue3組件庫(kù)如何使用?glup?打包組件庫(kù)并實(shí)現(xiàn)按需加載

    這篇文章主要介紹了從0搭建Vue3組件庫(kù)如何使用?glup?打包組件庫(kù)并實(shí)現(xiàn)按需加載,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-03-03
  • 深入探究Vue中探究組合式API的奧秘

    深入探究Vue中探究組合式API的奧秘

    Vue?3中引入了組合式API,它是一種新的代碼組織方式,旨在讓開(kāi)發(fā)者更靈活地組織和重用Vue組件的邏輯,下面我們就來(lái)學(xué)習(xí)一下Vue中常見(jiàn)組合式API的使用吧
    2023-11-11
  • elementUI組件中el-date-picker限制時(shí)間范圍精確到小時(shí)的方法

    elementUI組件中el-date-picker限制時(shí)間范圍精確到小時(shí)的方法

    現(xiàn)在需要做一個(gè)時(shí)間選擇器,可以根據(jù)小時(shí)(同時(shí)選天和小時(shí))和天?和月,節(jié)假日等類(lèi)型控制日歷的選擇樣式,下面這篇文章主要給大家介紹了關(guān)于elementUI組件中el-date-picker限制時(shí)間范圍精確到小時(shí)的相關(guān)資料,需要的朋友可以參考下
    2023-04-04
  • vuex實(shí)現(xiàn)數(shù)據(jù)持久化的兩種方案

    vuex實(shí)現(xiàn)數(shù)據(jù)持久化的兩種方案

    這兩天在做vue項(xiàng)目存儲(chǔ)個(gè)人信息的時(shí)候,遇到了頁(yè)面刷新后個(gè)人信息數(shù)據(jù)丟失的問(wèn)題,在查閱資料后,我得出兩種解決數(shù)據(jù)丟失,使用數(shù)據(jù)持久化的方法,感興趣的小伙伴跟著小編一起來(lái)看看吧
    2023-08-08
  • Vue Computed底層原理深入探究

    Vue Computed底層原理深入探究

    computed是vue的配置選項(xiàng),它的值是一個(gè)對(duì)象,其中可定義多個(gè)計(jì)算屬性,每個(gè)計(jì)算屬性就是一個(gè)函數(shù),下面這篇文章主要給大家介紹了關(guān)于vue中計(jì)算屬性computed的詳細(xì)講解,需要的朋友可以參考下
    2022-08-08
  • vue使用高德地圖根據(jù)坐標(biāo)定位點(diǎn)的實(shí)現(xiàn)代碼

    vue使用高德地圖根據(jù)坐標(biāo)定位點(diǎn)的實(shí)現(xiàn)代碼

    這篇文章主要介紹了vue使用高德地圖根據(jù)坐標(biāo)定位點(diǎn)的實(shí)現(xiàn)代碼,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-08-08

最新評(píng)論