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

Vue之el-select結(jié)合v-if動(dòng)態(tài)控制template顯示隱藏方式

 更新時(shí)間:2023年04月13日 10:57:04   作者:飛奔的大土豆  
這篇文章主要介紹了Vue之el-select結(jié)合v-if動(dòng)態(tài)控制template顯示隱藏方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

el-select結(jié)合v-if動(dòng)態(tài)控制template顯示隱藏

背景: 根據(jù)(取值方式)select框中當(dāng)選擇項(xiàng):

  • 1:范圍匹配的時(shí)候,(取值)顯示兩個(gè)輸入框(上線(xiàn),下線(xiàn));
  • 2:精確匹配的時(shí)候,(取值)顯示一個(gè)輸入框(精確)

代碼實(shí)現(xiàn)

<el-table-column label="取值方式" min-width="100" align="center">
?? ?<template scope="scope">
?? ??? ?<el-select v-model="scope.row.extractMode" clearable placeholder="請(qǐng)選擇">
?? ??? ??? ?<el-option v-for="item in extractModeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
?? ??? ?</el-select>
?? ?</template>
?? ?</el-table-column>
?? ?<el-table-column label="取值" min-width="300" align="center">
?? ?<template scope="scope"> <!-- v-if="!showExactMactchInput0" -->
?? ??? ?<div v-if="scope.row.extractMode== 'range' || scope.row.extractMode== 'fuzzy'"><!-- ?-->
?? ??? ??? ?<el-input size="small" class="limitTable" type="number" v-model="scope.row.lowerLimit" placeholder="請(qǐng)輸入下限內(nèi)容"></el-input>
?? ??? ??? ?-
?? ??? ??? ?<el-input size="small" class="limitTable" type="number" v-model="scope.row.upperLimit" placeholder="請(qǐng)輸入上線(xiàn)內(nèi)容"></el-input>
?? ??? ?</div>
?? ??? ?<div v-else-if="scope.row.extractMode== 'exacts' || scope.row.extractMode== 'exclude' " > <!-- v-bind:id="'exactlist-' + scope.$index" ref="'exactlist-' + scope.$index" -->
?? ??? ??? ?<el-input size="small" class="exactTable2" v-model="scope.row.exactMatch" placeholder="請(qǐng)輸入精確內(nèi)容"></el-input>
?? ??? ?</div>
?? ?</template>
?? ?</el-table-column>
?? ?<el-table-column label="操作" align="center">
?? ?<template slot-scope="scope">
?? ??? ?<el-button circle type="success" icon="el-icon-circle-plus" @click="handleLabelRowClone(scope.$index, scope.row)"></el-button>
?? ??? ?<el-button type="danger" icon="el-icon-remove" circle @click="handleLabelRowDelete(scope.$index, scope.row)"></el-button>
?? ?</template>
</el-table-column>

貼圖 

ps: 由于更入手vue,很多語(yǔ)法沒(méi)仔細(xì)看文檔,導(dǎo)致入坑不少;很多很簡(jiǎn)單的語(yǔ)法會(huì)耽擱時(shí)間;切記切記。

(坑:1:原本想用scope.$index[下標(biāo)]作為標(biāo)識(shí)從而v-if判斷;經(jīng)過(guò)實(shí)驗(yàn)變量無(wú)法進(jìn)行賦值(棄之)

2:用v-bind:id【scope.$index】 進(jìn)行dom控制style.display;考慮到vue本身僅關(guān)注視圖層;方式不優(yōu)好。(棄之)

3:恍惚間,每一行都獨(dú)立不就是【scope.$index】【scope.row】是同樣的;這樣也不用監(jiān)聽(tīng)v-select的change event。(用之)

v-if/else template任務(wù)狀態(tài){1,2,3};當(dāng)完成==3時(shí),跳轉(zhuǎn)ftp://

 <el-table-column label="任務(wù)狀態(tài)" prop="taskStatus">
    <template slot-scope="scope">
	<span v-if="scope.row.taskStatus=='3'" class="c-click" @click="hrefFtpUrl(scope.row)">            {{statusObj[scope.row.taskStatus] + scope.row.exportUrl}}</span>
    <span v-else >{{statusObj[scope.row.taskStatus]}}</span>
    </template>
		</el-table-column>

Vue動(dòng)態(tài)控制表格列的顯示隱藏

效果

如上圖所示,點(diǎn)擊table右上方的表格按鈕,彈出菜單欄,進(jìn)行勾選,從而達(dá)到表格對(duì)應(yīng)列顯示和隱藏

代碼

1.HTML部分

<template>
? <div id="app">
? ? <el-table :data="tableData" border style="width: 100%" ref="table">
? ? ? <el-table-column
? ? ? ? fixed
? ? ? ? prop="date"
? ? ? ? label="日期"
? ? ? ? width="150"
? ? ? ? v-if="showColumn.date"
? ? ? >
? ? ? </el-table-column>
? ? ? <el-table-column
? ? ? ? prop="name"
? ? ? ? label="姓名"
? ? ? ? width="120"
? ? ? ? v-if="showColumn.name"
? ? ? >
? ? ? </el-table-column>
? ? ? <el-table-column
? ? ? ? prop="province"
? ? ? ? label="省份"
? ? ? ? width="120"
? ? ? ? v-if="showColumn.provinces"
? ? ? >
? ? ? </el-table-column>
? ? ? <el-table-column
? ? ? ? prop="city"
? ? ? ? label="市區(qū)"
? ? ? ? width="120"
? ? ? ? v-if="showColumn.city"
? ? ? >
? ? ? </el-table-column>
? ? ? <el-table-column
? ? ? ? prop="address"
? ? ? ? label="地址"
? ? ? ? width="300"
? ? ? ? v-if="showColumn.adreess"
? ? ? >
? ? ? </el-table-column>
? ? ? <el-table-column
? ? ? ? prop="zip"
? ? ? ? label="郵編"
? ? ? ? width="120"
? ? ? ? v-if="showColumn.zipCode"
? ? ? >
? ? ? </el-table-column>
? ? ? <el-table-column fixed="right" width="100" align="center">
? ? ? ? <template slot="header">
? ? ? ? ? <i
? ? ? ? ? ? class="el-icon-setting"
? ? ? ? ? ? style="font-size: 22px; cursor: pointer"
? ? ? ? ? ? @click="showColumnOption"
? ? ? ? ? ></i>
? ? ? ? </template>
? ? ? ? <template slot-scope="scope">
? ? ? ? ? <el-button @click="handleClick(scope.row)" type="text" size="small"
? ? ? ? ? ? >查看</el-button
? ? ? ? ? >
? ? ? ? ? <el-button type="text" size="small">編輯</el-button>
? ? ? ? </template>
? ? ? </el-table-column>
? ? </el-table>
? ? <!-- 配置列面板 -->
? ? <transition name="fade">
? ? ? <div class="columnOption" v-show="isShowColumn">
? ? ? ? <div class="content">
? ? ? ? ? <div class="head">選擇顯示字段</div>
? ? ? ? ? <div class="body">
? ? ? ? ? ? <el-checkbox v-model="checkList.date" disabled>日期</el-checkbox>
? ? ? ? ? ? <el-checkbox v-model="checkList.name">姓名</el-checkbox>
? ? ? ? ? ? <el-checkbox v-model="checkList.provinces">省份</el-checkbox>
? ? ? ? ? ? <el-checkbox v-model="checkList.city">市區(qū)</el-checkbox>
? ? ? ? ? ? <el-checkbox v-model="checkList.adreess">地址</el-checkbox>
? ? ? ? ? ? <el-checkbox v-model="checkList.zipCode">郵編</el-checkbox>
? ? ? ? ? </div>
? ? ? ? ? <div class="footer">
? ? ? ? ? ? <el-button size="small" type="primary" plain @click="saveColumn"
? ? ? ? ? ? ? >保存列配置</el-button
? ? ? ? ? ? >
? ? ? ? ? </div>
? ? ? ? </div>
? ? ? </div>
? ? </transition>
? </div>
</template>

通過(guò) v-if="showColumn.date" 來(lái)判斷表格對(duì)應(yīng)列的狀態(tài)

2.javascript部分

<script>
export default {
? data() {
? ? return {
? ? ? isShowColumn: false,
? ? ? tableData: [
? ? ? ? {
? ? ? ? ? date: "2016-05-02",
? ? ? ? ? name: "王小虎",
? ? ? ? ? province: "上海",
? ? ? ? ? city: "普陀區(qū)",
? ? ? ? ? address: "上海市普陀區(qū)金沙江路 1518 弄",
? ? ? ? ? zip: 200333,
? ? ? ? },
? ? ? ? {
? ? ? ? ? date: "2016-05-04",
? ? ? ? ? name: "王小虎",
? ? ? ? ? province: "上海",
? ? ? ? ? city: "普陀區(qū)",
? ? ? ? ? address: "上海市普陀區(qū)金沙江路 1517 弄",
? ? ? ? ? zip: 200333,
? ? ? ? },
? ? ? ? {
? ? ? ? ? date: "2016-05-01",
? ? ? ? ? name: "王小虎",
? ? ? ? ? province: "上海",
? ? ? ? ? city: "普陀區(qū)",
? ? ? ? ? address: "上海市普陀區(qū)金沙江路 1519 弄",
? ? ? ? ? zip: 200333,
? ? ? ? },
? ? ? ? {
? ? ? ? ? date: "2016-05-03",
? ? ? ? ? name: "王小虎",
? ? ? ? ? province: "上海",
? ? ? ? ? city: "普陀區(qū)",
? ? ? ? ? address: "上海市普陀區(qū)金沙江路 1516 弄",
? ? ? ? ? zip: 200333,
? ? ? ? },
? ? ? ],
? ? ? // 列的配置化對(duì)象,存儲(chǔ)配置信息
? ? ? checkList: {},
? ? ? showColumn: {
? ? ? ? date: true,
? ? ? ? name: true,
? ? ? ? provinces: true,
? ? ? ? city: true,
? ? ? ? adreess: true,
? ? ? ? zipCode: true,
? ? ? },
? ? };
? },
? watch: {
? ? // 監(jiān)聽(tīng)復(fù)選框配置列所有的變化
? ? checkList: {
? ? ? handler: function (newnew, oldold) {
? ? ? ? // console.log(newnew);?
? ? ? ? this.showColumn = newnew;
? ? ? ? // 這里需要讓表格重新繪制一下,否則會(huì)產(chǎn)生固定列錯(cuò)位的情況
? ? ? ? this.$nextTick(() => {
? ? ? ? ? this.$refs.table.doLayout();
? ? ? ? });
? ? ? },
? ? ? deep: true,
? ? ? immediate: true
? ? },
? },
? mounted() {
? ? // 發(fā)請(qǐng)求得到checkListInitData的列的名字
? ? if(localStorage.getItem("columnSet")){
? ? ? this.checkList = JSON.parse(localStorage.getItem("columnSet"))
? ? }else{
? ? ? this.checkList = {
? ? ? ? date: true,
? ? ? ? name: true,
? ? ? ? provinces: true,
? ? ? ? city: true,
? ? ? ? adreess: true,
? ? ? ? zipCode: true,
? ? ? };
? ? }
? },
? methods: {
? ? handleClick(row) {
? ? ? console.log(row);
? ? },
? ? showColumnOption() {
? ? ? this.isShowColumn = true;
? ? },
? ? saveColumn() {
? ? ? localStorage.setItem("columnSet",JSON.stringify(this.checkList))
? ? ? this.isShowColumn = false;
? ? },
? },
};
</script>

3.css樣式部分

.columnOption {
? position: fixed;
? z-index: 20;
? top: 0;
? left: 0;
? width: 100%;
? height: 100%;
? background-color: rgba(0, 0, 0, 0.3);
? display: flex;
? flex-direction: row-reverse;
? .content {
? ? width: 100px;
? ? height: 100%;
? ? background-color: rgb(203, 223, 198);
? ? .head {
? ? ? width: 100%;
? ? ? height: 44px;
? ? ? border-bottom: 1px solid #000;
? ? ? display: flex;
? ? ? justify-content: center;
? ? ? align-items: center;
? ? ? font-size: 12px;
? ? }
? ? .body {
? ? ? width: 100%;
? ? ? height: calc(100% - 88px);
? ? ? box-sizing: border-box;
? ? ? padding-top: 10px;
? ? ? overflow-y: auto;
? ? ? .items {
? ? ? ? width: 100%;
? ? ? ? height: 100%;
? ? ? ? overflow-y: auto;
? ? ? ? display: flex;
? ? ? ? flex-direction: column;
? ? ? ? .el-checkbox {
? ? ? ? ? width: 100%;
? ? ? ? ? height: 28px;
? ? ? ? ? line-height: 28px;
? ? ? ? ? margin-bottom: 14px;
? ? ? ? ? display: inline-block;
? ? ? ? ? font-family: PingFang SC;
? ? ? ? ? font-style: normal;
? ? ? ? ? font-weight: normal;
? ? ? ? ? font-size: 14px;
? ? ? ? ? color: #000;
? ? ? ? ? overflow: hidden;
? ? ? ? ? text-overflow: ellipsis;
? ? ? ? ? white-space: nowrap;
? ? ? ? ? box-sizing: border-box;
? ? ? ? ? padding-left: 14px;
? ? ? ? }
? ? ? ? .el-checkbox:hover {
? ? ? ? ? background-color: #f5f7fa;
? ? ? ? }
? ? ? }
? ? }
? ? .footer {
? ? ? width: 100%;
? ? ? height: 44px;
? ? ? border-top: 1px solid #000;
? ? ? display: flex;
? ? ? justify-content: center;
? ? ? align-items: center;
? ? }
? }
}
// 控制淡入淡出效果
.fade-enter-active,
.fade-leave-active {
? transition: opacity 0.3s;
}
.fade-enter,
.fade-leave-to {
? opacity: 0;
}

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue定義模態(tài)框的方法

    vue定義模態(tài)框的方法

    這篇文章主要為大家詳細(xì)介紹了vue定義模態(tài)框的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • 使用Vuex實(shí)現(xiàn)一個(gè)筆記應(yīng)用的方法

    使用Vuex實(shí)現(xiàn)一個(gè)筆記應(yīng)用的方法

    這篇文章主要介紹了使用Vuex實(shí)現(xiàn)一個(gè)筆記應(yīng)用的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-03-03
  • 使用Vue開(kāi)發(fā)動(dòng)態(tài)刷新Echarts組件的教程詳解

    使用Vue開(kāi)發(fā)動(dòng)態(tài)刷新Echarts組件的教程詳解

    這篇文章主要介紹了使用Vue開(kāi)發(fā)動(dòng)態(tài)刷新Echarts組件的教程詳解,需要的朋友可以參考下
    2018-03-03
  • 利用Vue3實(shí)現(xiàn)可復(fù)制表格的方法詳解

    利用Vue3實(shí)現(xiàn)可復(fù)制表格的方法詳解

    表格是前端非常常用的一個(gè)控件,本文主要為大家介紹了Vue3如何實(shí)現(xiàn)一個(gè)簡(jiǎn)易的可以復(fù)制的表格,文中的示例代碼講解詳細(xì),需要的可以參考一下
    2022-12-12
  • vue實(shí)現(xiàn)多級(jí)菜單效果

    vue實(shí)現(xiàn)多級(jí)菜單效果

    這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)多級(jí)菜單效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-07-07
  • Vue3實(shí)現(xiàn)密碼加密登錄的示例代碼

    Vue3實(shí)現(xiàn)密碼加密登錄的示例代碼

    現(xiàn)在,很多登陸表單都會(huì)使用密碼加密,為登錄安全,登錄表單輸入密碼,會(huì)加密后傳入后臺(tái),本文就來(lái)介紹一下Vue3實(shí)現(xiàn)密碼加密登錄的示例代碼,具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-02-02
  • 詳解Vue數(shù)據(jù)驅(qū)動(dòng)原理

    詳解Vue數(shù)據(jù)驅(qū)動(dòng)原理

    這篇文章主要介紹了詳解Vue數(shù)據(jù)驅(qū)動(dòng)原理的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)vue框架的相關(guān)知識(shí),感興趣的朋友可以了解下
    2020-11-11
  • 一個(gè)Vue視頻媒體多段裁剪組件的實(shí)現(xiàn)示例

    一個(gè)Vue視頻媒體多段裁剪組件的實(shí)現(xiàn)示例

    這篇文章主要介紹了一個(gè)Vue媒體多段裁剪組件的實(shí)現(xiàn)示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-08-08
  • vue初嘗試--項(xiàng)目結(jié)構(gòu)(推薦)

    vue初嘗試--項(xiàng)目結(jié)構(gòu)(推薦)

    這篇文章主要介紹了vue初嘗試--項(xiàng)目結(jié)構(gòu)的相關(guān)知識(shí),需要的朋友可以參考下
    2018-01-01
  • vue項(xiàng)目總結(jié)之文件夾結(jié)構(gòu)配置詳解

    vue項(xiàng)目總結(jié)之文件夾結(jié)構(gòu)配置詳解

    這篇文章主要給大家總結(jié)介紹了關(guān)于vue項(xiàng)目之文件夾結(jié)構(gòu)配置的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-12-12

最新評(píng)論