当前位置:网站首页>5. Display of component dynamic components
5. Display of component dynamic components
2022-07-27 04:36:00 【Taoist priest IOT】
Don't talk much , Show all the code directly , Specific comments are in the content , Open the box
<template>
<div class="container">
<span :class="checked === item.id ? 'active' : ''" v-for="(item, index) in btnList" :key="item.id" @click="changeTabs(item)">{
{ item.name }}</span>
<div>
<!-- Here is the attribute name of the dynamic switching component -->
<component :is="current.Name"></component>
</div>
</div>
</template>
<script setup> import {
reactive, ref, markRaw } from 'vue' import A from '@/components/canChangeCom/comA.vue' import B from '@/components/canChangeCom/comB.vue' import C from '@/components/canChangeCom/comC.vue' // Data of dynamic components // Why do I use markRaw markRaw Data can be cancelled proxy agent const btnList = reactive([ {
id: 1, name: 'A' , comName: markRaw(A)}, {
id: 2, name: 'B' , comName: markRaw(B)}, {
id: 3, name: 'C' , comName: markRaw(C)}, ]) // They have no variable escalation , When I need to use the above data for the following data , I have to put data at the bottom // Set the components displayed by default let current = reactive({
Name: btnList[0].comName }) // Here is the default selected button , Let him be the first by default let checked = ref(1) const changeTabs = (item) => {
// Highlight the selected button checked.value = item.id // Currently displayed components current.Name = item.comName } </script>
<style lang="scss" scoped> .container {
width: 100%; height: 500px; border: 3px solid #ccc; span {
display: inline-block; width: 100PX; border: 1px solid #ccc; text-align: center; margin-left: 10px; margin-top: 10px; cursor: pointer; } .active {
background: orange; } } </style>
边栏推荐
- Scala immutable map, variable map, map conversion to other data types
- Understand kingbasees V9 in one picture
- JS第二天(变量、变量的使用、命名规则、语法扩展)
- 安全第四次课后练习
- GenericServlet为什么有两个init方法
- [competition reference] pytorch common code snippet and operation collection
- 题目:有一个已经按升序排好序的数组。现输入一个数,要求按原来的规律将它插入数组中。
- Use the kubesphere graphical interface dashboard to enable the Devops function
- [machine learning network] BP neural network and deep learning-6 deep neural networks (DNN)
- Network knowledge corner | it only takes four steps to teach you to use SecureCRT to connect to ENSP. You must see the operation guide of common tools
猜你喜欢

卷积神经网络——24位彩色图像的卷积的详细介绍

Do you know about wechat merchant billing?

Okaleido tiger will log in to binance NFT in the second round, or continue to create sales achievements

从零开始C语言精讲篇4:数组

2022-07-26:以下go语言代码输出什么?A:5;B:hello;C:编译错误;D:运行错误。 package main import ( “fmt“ ) type integer in

【HCIP】重发布、重分布、重分发实验

【独立站建设】跨境电商出海开网店,首选这个网站建设!

iPhone13再降价,其实只是做做样子,消费者都在等iPhone14

e. The difference between target and e.currenttarget

Deep analysis - dynamic memory management
随机推荐
ELS square display principle
Ribbon load balancing strategy and configuration, lazy loading and hungry loading of ribbon
QString转换char*
RSA asymmetric encryption and decryption signature verification tool
电商分账系统重要吗,平台应该如何选择分账服务商呢?
Do you know about wechat merchant billing?
shell编程增强
Plato farm has a new way of playing, and the arbitrage eplato has secured super high returns
timestamp列使用varchar类型和使用date类型有什么区别?
IP第十四天笔记
People don't talk much, engineers don't talk much
RN开发系列<9>--Mobx(1)入门篇
Ref Hook
安全第四次课后练习
Preliminary understanding of NiO
Px4 module design 12: high resolution timer design
Overview of communication protocols
【动态规划百题强化计划】11~20(持续更新中)
Effect Hook
【独立站建设】跨境电商出海开网店,首选这个网站建设!