Element-ui 动态tabs实战

本文讲述了如何将原有的页面逻辑优化成Element-ui动态tabs的效果。需求是在点击一列数据后,不再跳出子页面,而是通过动态tabs实现页面切换。通过路由调整将页面定位到DataRetrievalTabs.vue,并在点击事件中将DataRetrieval页面添加到tabList进行渲染。同时实现了添加新tab和一键删除其他tab的功能。在实现过程中遇到的报错是由于参数类型不匹配,通过将数字转换为字符串解决了问题。
摘要由CSDN通过智能技术生成

先梳理一下需求,原先的页面逻辑如下:

在一个大的页面中改动一个子组件 

一列数据,点击后跳出一个子页面覆盖了父页面,里面使用到的是Vuex的目录调用,项目经理希望通过优化页面达到,element-ui 动态tabs的效果,如图所示:

 这种第一个页面不允许删除,其余点击后tab自动增加,还需要具备一个一键删除其他页面的功能。

我们先看看原代码的逻辑结构:

在主页面DataRetrieval.vue中:

<template>
    <el-container class="tydic-container-wrap flex-layout-parent flex-layout-child">
        <div v-loading="listLoading">
            <div v-for="(item, index) in tableInfoList" :key="item.tableId" class="dataRetrivalItem">
                <el-row class="itemRow">
                    <el-col :span="8"><el-button type="text" @click="modelDetailBtn(item.modelId, item.modelCode, item.modelDbName, item.modelName, item.isExistTable)">{
  {item.modelCode}}</el-button></el-col>
                    <el-col :span="8"><label>中文名称:</label>{
  {item.modelName}}</el-col>
                </el-row>
                <el-row class="itemRow">
                    <el-col :span="8"><label>类目:</label><span :title="item.modelCategory">{
  {item.modelCategory}}</span></el-col>
                    <!-- <el-col :span="8"><label>项目:</label><span :title="item.modelProjectId">{
  {projectNameFmt(item.modelProjectId)}}</span></el-col> -->
                    <el-col :span="8"><label>拥有者:</label><span :title="item.modelOwner">{
  {item.modelOwner}}</span></el-col>
                    <el-col :span="8"><label>最新更新时间:</label><span :title="item.modelUptdate">{
  {item.modelUptdate}}</span></el-col>
                </el-row>
                <el-row class="itemRow" >
                    <el-col :span="24" style="overflow:hidden;text-overflow:ellipsis;white-space:wrap"><label>描述:</label><span :title="item.modelDesc">{
  {item.modelDesc}}</span></el-col>
                </el-row>
            </div>
        </div>

    </el-container>
</template>

<script>

    const ModelDetail = resolve => require(['@/views/dataManager/dataRetrieval/ModelDetail'], resolve)

    export default {
        components: {
            // ModelD
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值