当前位置:网站首页>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>
边栏推荐
- Common colors for drawing
- 关于三子棋游戏的简易实现与N子棋胜利判断方法
- 汇编标志位相关知识点(连)
- [转]以终为始,详细分析高考志愿该怎么填
- Sword finger offer day 1 stack and queue (simple)
- @Scheduled implementation of scheduled tasks (concurrent execution of multiple scheduled tasks)
- 三行代码简单修改jar包的项目代码
- [flask tutorial] flask overview
- 數據在內存中的存儲相關內容
- Spoken English - weak reading
猜你喜欢

Maui的学习之路(二)--设置

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

@Scheduled implementation of scheduled tasks (concurrent execution of multiple scheduled tasks)

一篇文章讲清楚MySQL的聚簇/联合/覆盖索引、回表、索引下推

WIN10环境下配置pytorch

二叉树之_哈夫曼树_哈弗曼编码

Golang keyboard input statement scanln scanf code example

Of binary tree_ Huffman tree_ Huffman encoding

Stockage des données en mémoire

It's an artifact to launch a website in a few minutes
随机推荐
Sword finger offer II 029 Sorted circular linked list
关于扫雷的简易实现
剑指 Offer 04. 二维数组中的查找
Uncover gaussdb (for redis): comprehensive comparison of CODIS
Spoken English - weak reading
指针,它那些不得不说的题目
剑指offer 第 3 天字符串(简单)
ByteDance dev better technology salon is coming! Participate in the activity to win a good gift, and sign up for free within a limited time!
Analyse de l'optimisation de la réécriture des requêtes lazyagg de l'entrepôt
It's an artifact to launch a website in a few minutes
[machine learning] what is machine learning?
Django框架——缓存、信号、跨站请求伪造、 跨域问题、cookie-session-token
Which Chinese virtual human is better? Sullivan, IDC: Xiaobing Baidu Shangtang ranks in the first echelon
Summer Ending
Serenvlt first met
Django framework - caching, signaling, cross site request forgery, cross domain issues, cookie session token
There is a problem with the date when MySQL imports and exports data to excel
CUDA error: unspecified launch failure
Capabilities required by architects
QT display ffmpeg decoded pictures