最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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: '請輸入要搜索的測試名稱'
 }
 },
 created () {
 this.setSelectItems()
 this.setInitType()
 },
 methods: {
 setSelectItems () {
  this.selectItems = [{
  value: '測試名',
  label: '測試名'
  }, {
  value: '測試ID',
  label: '測試ID'
  }]
 },
 changeType (newType) {
  if (newType === '測試名') {
  this.placeholderDes = '請輸入要搜索的測試名稱'
  this.selectStatus = 'name'
  } else if (newType === '測試ID') {
  this.placeholderDes = '請輸入要搜索的測試ID'
  this.selectStatus = 'id'
  }
 },
 searchOk (value) {
  console.log(this.selectStatus)
  console.log(value)
  // 調(diào)用你的搜索接口,搜索條件為搜索的類型 + 搜索值
  // yourSearch (this.selectStatus, value)
 },
 setInitType () {
  this.initType = '測試名'
 }
 },
 components: {
 VSearch
 }
}
</script>

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

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

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

相關(guān)文章

  • 關(guān)于json-bigint處理大數(shù)字問題

    關(guān)于json-bigint處理大數(shù)字問題

    這篇文章主要介紹了關(guān)于json-bigint處理大數(shù)字問題,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • Vue el-table復(fù)選框全部勾選及勾選回顯功能實(shí)現(xiàn)

    Vue el-table復(fù)選框全部勾選及勾選回顯功能實(shí)現(xiàn)

    這篇文章主要介紹了Vue el-table復(fù)選框全部勾選及勾選回顯功能實(shí)現(xiàn),本文通過示例代碼給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧
    2024-05-05
  • vue 獲取及修改store.js里的公共變量實(shí)例

    vue 獲取及修改store.js里的公共變量實(shí)例

    今天小編就為大家分享一篇vue 獲取及修改store.js里的公共變量實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-11-11
  • 前端vue如何監(jiān)聽對象或者數(shù)組某個(gè)屬性的變化詳解

    前端vue如何監(jiān)聽對象或者數(shù)組某個(gè)屬性的變化詳解

    這篇文章主要給大家介紹了關(guān)于前端vue如何監(jiān)聽對象或者數(shù)組某個(gè)屬性的變化的相關(guān)資料,在Vue中你可以使用watch或者computed來監(jiān)聽對象或數(shù)組某個(gè)屬性的變化,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-03-03
  • vue實(shí)現(xiàn)前臺列表數(shù)據(jù)過濾搜索、分頁效果

    vue實(shí)現(xiàn)前臺列表數(shù)據(jù)過濾搜索、分頁效果

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)前臺列表數(shù)據(jù)過濾搜索、分頁效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-05-05
  • Vue 組件注冊全解析

    Vue 組件注冊全解析

    這篇文章主要介紹了Vue 組件注冊全解析的相關(guān)資料,幫助大家更好的理解和使用vue,感興趣的朋友可以了解下
    2020-12-12
  • vue + element-ui實(shí)現(xiàn)簡潔的導(dǎo)入導(dǎo)出功能

    vue + element-ui實(shí)現(xiàn)簡潔的導(dǎo)入導(dǎo)出功能

    Element-UI是餓了么前端團(tuán)隊(duì)推出的一款基于Vue.js 2.0 的桌面端UI框架,手機(jī)端有對應(yīng)框架是 Mint UI,下面這篇文章主要給大家介紹了關(guān)于利用vue + element-ui如何實(shí)現(xiàn)簡潔的導(dǎo)入導(dǎo)出功能的相關(guān)資料,需要的朋友可以參考下。
    2017-12-12
  • vue實(shí)現(xiàn)網(wǎng)頁語言國際化切換

    vue實(shí)現(xiàn)網(wǎng)頁語言國際化切換

    這篇文章介紹了vue實(shí)現(xiàn)網(wǎng)頁語言國際化切換的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2021-11-11
  • vue實(shí)現(xiàn)日歷表格(element-ui)

    vue實(shí)現(xiàn)日歷表格(element-ui)

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)日歷表格(element-ui),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-09-09
  • vue?watch中如何獲取this.$refs.xxx節(jié)點(diǎn)

    vue?watch中如何獲取this.$refs.xxx節(jié)點(diǎn)

    這篇文章主要介紹了vue?watch中獲取this.$refs.xxx節(jié)點(diǎn)的方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-08-08

最新評論

若尔盖县| 达孜县| 武冈市| 东丰县| 新郑市| 托克逊县| 敦煌市| 彰化县| 镶黄旗| 卢龙县| 桐乡市| 五峰| 康马县| 襄城县| 汉中市| 苍梧县| 翁源县| 龙井市| 泰兴市| 兰州市| 浠水县| 伊通| 增城市| 五台县| 宜君县| 铜山县| 花莲县| 亳州市| 丹凤县| 宁城县| 来凤县| 天峻县| 金阳县| 成安县| 安徽省| 兴隆县| 黎川县| 绵阳市| 工布江达县| 金秀| 乡宁县|