zoukankan      html  css  js  c++  java
  • vue 组件用法

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <script type="text/javascript" src="../assets/js/vue.js"></script>
        <title>component</title>
    </head>
    <body>
        <h1>component-4</h1>
        <hr>
        <div id="app">
           <component v-bind:is="who"></component>
           <button @click="changeComponent">changeComponent</button>
        </div>
     
        <script type="text/javascript">
            var componentA={
                template:`<div style="color:red;">I'm componentA</div>`
            }
            var componentB={
                template:`<div style="color:green;">I'm componentB</div>`
            }
            var componentC={
                template:`<div style="color:pink;">I'm componentC</div>`
            }
           
            var app=new Vue({
                el:'#app',
                data:{
                    who:'componentA'
                },
                components:{
                    "componentA":componentA,
                    "componentB":componentB,
                    "componentC":componentC,
                },
                methods:{
                    changeComponent:function(){
                        if(this.who=='componentA'){
                            this.who='componentB';
                        }else if(this.who=='componentB'){
                            this.who='componentC';
                        }else{
                            this.who='componentA';
                        }
                    }
                }
            })
        </script>
    </body>
    </html>
  • 相关阅读:
    bootstrap 弹出框(Popover)插件 修改title等属性选项值
    dedecms 搬家流程
    jQuery ui 百叶窗blind方向设置
    css 优先级
    dedecms 标签
    dedecms 建站相关问题
    css 透明度使用
    css 边框使用
    css 阴影使用
    js 常用判断
  • 原文地址:https://www.cnblogs.com/qq735675958/p/9163314.html
Copyright © 2011-2022 走看看