zoukankan      html  css  js  c++  java
  • vue.js基础__componen 标签

    以代码为例:
     
    <!DOCTYPE html>
    <html lang="en">

    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>component-4 标签</title>
    <script src="../assets/js/vue.js"></script>
    </head>

    <body>
    <h1>component-4 标签</h1>
    <hr>
    <div id="app">
    <component :is="who"></component>
    <button @click="changeComponent">changeComponent</button>
    </div>

    <script>

    var componentA = {
    template: `<div style="color:red;">componentA</div>`
    }
    var componentB = {
    template: `<div style="color:yellow;">componentB</div>`
    }
    var componentC = {
    template: `<div style="color:green;">componentC</div>`
    }

    var app = new Vue({
    el: '#app',
    data: {
    who: 'componentC'
    },
    components: {
    'componentA': componentA,
    'componentB': componentB,
    'componentC': componentC
    },
    methods: {
    changeComponent() {
    if (this.who == 'componentA') {
    this.who = 'componentB'
    } else if (this.who == 'componentB') {
    this.who = 'componentC'
    } else {
    this.who = 'componentA'
    }
    }
    }
    })
    </script>
    </body>

    </html>

  • 相关阅读:
    随机数生成器
    赌博的艺术
    基本算法——包罗万象
    对于搜索的新理解
    关于动态规格的新理解
    发现的好东西——bitset
    高精度(重定义版)——来自
    ac自动机(模板)
    数据采集框架Gobblin简介
    Hadoop的数据采集框架
  • 原文地址:https://www.cnblogs.com/sunyang-001/p/11101388.html
Copyright © 2011-2022 走看看