Detailed explanation of vue.js dynamic components

Detailed explanation of vue.js dynamic components

:is dynamic component

Use v-bind:is="component name" to automatically find a matching component name. If there is no matching component name, it will not be displayed.

<div id="app">
    <test v-bind:is="which_to_show"></test>
</div>

<script>
    var demo = new Vue({
        el: "#app",
        data: {
            which_to_show: "first"
        },
        components:
            first: {
                template: "<div>Here is the subcomponent first</div>"
            },
            second: {
                template: "<div>Here is the subcomponent second</div>"
            },
            third: {
                template: "<div>Here is the subcomponent third</div>"
            }
        }
    });
</script>

Write the picture description here

By changing the value of which_to_show, you can dynamically change the component you want to load and render, as follows:

Write the picture description here

This is the end of this article about the detailed explanation of vue.js dynamic components. For more relevant vue.js dynamic component content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Vue.js dynamic component analysis
  • Vue.js parent-child component communication dynamic binding example
  • Implementation of dynamic component templates in Vue.js
  • Detailed explanation of the usage of scoped slots in Vue.js slots
  • Front-end architecture vue architecture slot usage tutorial
  • Basic usage specifications of slots in Vue2
  • Vue default slot, named slot, scope slot definition and usage
  • Summary of the use of vue.js dynamic components and slots

<<:  Detailed explanation of MySQL foreign key constraints

>>:  Detailed tutorial on building a private Git server on Linux

Recommend

Explanation and example usage of 4 custom instructions in Vue

Four practical vue custom instructions 1. v-drag ...

Summary of MySQL character sets

Table of contents Character Set Comparison Rules ...

Solution to 1449 and 1045 exceptions when connecting to MySQL

Solution to 1449 and 1045 exceptions when connect...

Detailed explanation of slave_exec_mode parameter in MySQL

Today I accidentally saw the parameter slave_exec...

MySQL 8.0.21 installation tutorial under Windows system (illustration and text)

Installation suggestion : Try not to use .exe for...

WeChat applet implements waterfall flow paging scrolling loading

This article shares the specific code for WeChat ...

Full steps to create a high-performance index in MySQL

Table of contents 1. Index Basics 1. Types of Ind...

A brief analysis of the use of zero copy technology in Linux

This article discusses several major zero-copy te...

Use of MySQL trigger

Table of contents 1. Trigger Introduction 1. What...

CSS code to achieve 10 modern layouts

Preface I watched web.dev's 2020 three-day li...

How to recover data after accidentally deleting ibdata files in mysql5.7.33

Table of contents 1. Scenario description: 2. Cas...

Quick understanding and example application of Vuex state machine

Table of contents 1. Quick understanding of conce...

Detailed explanation of Vue Notepad example

This article example shares the specific code of ...

Analysis of Difficulties in Hot Standby of MySQL Database

I have previously introduced to you the configura...