当前位置:网站首页>Component: is to switch between multiple components
Component: is to switch between multiple components
2022-06-25 13:16:00 【liminla!】
component :is Switch between multiple components
Parent component
<template>
<div>
<div
:class="{ active: index === activeIndex }"
v-for="(item, index) in menuList"
:key="item.name"
@click="tabChange(index, item.name)"
>
{
{
item.name }}
</div>
</div>
<component
:is="menuActive"
:id="id"
:ref="menuActive"
></component>
</div>
</template>
<script>
import A from "./components/a";
import B from "./components/b";
import C from "./components/C";
export default {
components: {
A, B, C},
data() {
return {
id:undefined,
menuActive: "",
menuList:[
{
name:'A',component:'A'},
{
name:'B',component:'B'},
{
name:'C',component:'C'},
]
}
},
mounted() {
this.tabChange(0);
},
methods: {
tabChange(index, item) {
this.menuActive = this.menuList[index].component;
setTimeout(() => {
this.$refs[this.menuActive].init();
}, 20);
},
},
}
</script>
Child components
<template>
<div>
</div>
</template>
<script>
export default {
props: {
id: {
type: String,
default: "",
},
data() {
return {
}
},
mounted() {
},
methods: {
init() {
this.getData();// Call interface to get data
},
},
}
</script>
边栏推荐
- Assemble relevant knowledge points of flag bit (connected)
- Back test of quantitative trading - example of futures CTA strategy (tqzfuturerenkoscalpingstrategy)
- Spoken English - weak reading
- MySQL adds, modifies, and deletes table fields, field data types, and lengths (with various actual case statements)
- AGCO AI frontier promotion (6.25)
- KVM 脚本管理 —— 筑梦之路
- leetcode - 384. 打乱数组
- 原生js---无限滚动
- 關於數據在內存中的存儲下
- Fedora 35 部署DNS主从和分离解析 —— 筑梦之路
猜你喜欢

Fedora 35 部署DNS主从和分离解析 —— 筑梦之路

Optimization of lazyagg query rewriting in parsing data warehouse

关于数据在内存中的存储下

The editor is used every day. What is the working principle of language service protocol?

Update PIP & Download jupyter Lab

Online service emergency research methodology

Koa 框架

Sword finger offer II 032 Effective anagrams

剑指Offer 第 2 天链表(简单)

@Scheduled implementation of scheduled tasks (concurrent execution of multiple scheduled tasks)
随机推荐
Fedora 35 deploys DNS master-slave and separation resolution -- the way to build a dream
[turn] starting from the end, analyze in detail how to fill in the college entrance examination volunteer
Reload cuda/cudnn/pytorch
Where is it safe to open an account for buying funds? Please give me your advice
时间过滤器(el-table)中使用
Sword finger offer II 032 Effective anagrams
Resolution of PPT paper drawing
Oracle backup or restore database (expdp, impdp)
重磅直播|BizDevOps:数字化转型浪潮下的技术破局之路
New Gospel of drug design: Tencent, together with China University of science and technology and Zhejiang University, developed an adaptive graph learning method to predict molecular interactions and
Sword finger offer II 028 Flatten multi-level bidirectional linked list
剑指 Offer II 028. 展平多级双向链表
1024 hydrology
數據在內存中的存儲相關內容
You can't specify target table 'xxx' for update in from clause
[machine learning] what is machine learning?
词法陷阱(C)
Native JS --- infinite scrolling
深圳民太安智能二面_秋招第一份offer
關於數據在內存中的存儲下