Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
275 views
in Technique[技术] by (71.8m points)

elementUI NavMenu怎样切换页面上的表格

如图,tab1和tab2下面分别有两个不同的表格,怎样通过NavMenu切换两个表格
微信截图_20200511165157.png

<template>
  <div class="resignation">
      <div class="clearfix">
        <el-menu :default-active="activeIndex" active-text-color="#1890ff" class="el-menu-demo" mode="horizontal" @select="handleSelect">
            <el-menu-item index="1">tab1</el-menu-item>
            <el-menu-item index="2">tab2</el-menu-item>
        </el-menu>
      </div>
      <div class="correct-wait">
        <el-table
            class="waitTable"
            size="small"
            :data="tableData.records"
            :key="tableKey"
            @selection-change="onSelectChange"
            @sort-change="sortChange"
            border
            fit
            ref="table"
            style="width: 100%;"
            v-loading="loading"
        >
            <el-table-column align="center" type="selection" width="55px" />
            <el-table-column align="center" label="表格1" type="index" width="70"></el-table-column>
        </el-table>
        <el-table
            class="waitTable"
            size="small"
            :data="tableData.records"
            :key="tableKey"
            @selection-change="onSelectChange"
            @sort-change="sortChange"
            border
            fit
            ref="table"
            style="width: 100%;"
            v-loading="loading"
        >
            <el-table-column align="center" type="selection" width="55px" />
            <el-table-column align="center" label="表格2" type="index" width="70"></el-table-column>
        </el-table>
      </div>
  </div>
</template>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

<el-tabs> 更符合需求。如果是非要用 <el-menu> 那么在 handleSelect 回调中有 index 可以判断当前是那个。

image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.7k users

...