当前位置:网站首页>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>
边栏推荐
- shel自动设置目录权限
- Title: there is an array that has been sorted in ascending order. Now enter a number and ask to insert it into the array according to the original rule.
- 结构型模式-桥接模式
- BSN IPFS(星际文件系统)专网简介、功能、架构及特性、接入说明
- The project parameters are made into configurable items, and the @configurationproperties annotation is used
- Pinia入门到精通,Pinia使用全流程,包含state,actions,getters,以及如何解构,进行响应,actions使用的多种方法
- Eureka service registry
- Brightcove任命Dan Freund为首席营收官
- 结构型模式-外观(Facade)模式
- State Hook
猜你喜欢
![[day02] Introduction to data type conversion, operators and methods](/img/81/e2c49a4206e5d0d05308a1fc881626.png)
[day02] Introduction to data type conversion, operators and methods

Unity:Resource Merging、Static Batching、Dynamic Batching、GPU Instancing
深度学习领域图像分割FCN(Fully Convolutional Networks for Semantic Segmentation)

Plato farm has a new way of playing, and the arbitrage eplato has secured super high returns

Spark practice case (upgraded version)

可视化领域 SVG

Okaleido ecological core equity Oka, all in fusion mining mode

Elastic open source community: Developer Recruitment

Detailed explanation of TCP protocol knowledge

Remember the major performance problems caused by a TCP packet loss
随机推荐
Ribbon load balancing principle and some source codes
P1438 boring sequence line segment tree + difference
els 兼容性DC、传递图片到窗口
Influxdb basic understanding
Why does genericservlet have two init methods
0动态规划中等 LeetCode467. 环绕字符串中唯一的子字符串
Session&Cookie&token
BSN IPFs (interstellar file system) private network introduction, functions, architecture and characteristics, access instructions
Spark practice case (upgraded version)
【day02】数据类型转换、运算符、方法入门
人很话不多,工程师不耍嘴皮子
题目:有一个已经按升序排好序的数组。现输入一个数,要求按原来的规律将它插入数组中。
微信小程序编辑头像
shell编程增强
Maximum value, minimum value, bubble sort in the array
VSCode开启Pull Request更新代码分支可视化新篇章
Sed output specified line
[competition reference] pytorch common code snippet and operation collection
ros 相机标定 sensor_msgs/CameraInfo Message 数据类型及含义
Anonymous named pipes, understanding and use of interprocess communication in shared memory