zoukankan      html  css  js  c++  java
  • vue21 slot占位

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <script src="bower_components/vue/dist/vue.js"></script>
        <style>
        </style>
    </head>
    <body>
    <!--slot:
        位置、槽口
        作用: 占个位置
    
        类似ng里面 transclude  (指令)-->
        <div id="box">
            <aaa>
                <ul> <!--出不来-->
                    <li>1111</li>
                    <li>2222</li>
                    <li>3333</li>
                </ul>
            </aaa>
        </div>
    
        <script>
            var vm=new Vue({
                el:'#box',
                data:{
                    a:'aaa'
                },
                components:{
                    'aaa':{
                        template:'<h1>xxxx</h1>'
                    }
                }
            });
    
        </script>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <script src="bower_components/vue/dist/vue.js"></script>
        <style>
        </style>
    </head>
    <body>
        <div id="box">
            <aaa>
                <ul>
                    <li>1111</li>
                    <li>2222</li>
                    <li>3333</li>
                </ul>
            </aaa>
        </div>
        <template id="aaa">
            <h1>xxxx</h1>
            <slot>这是默认的情况</slot> <!--ul出来了-->
            <p>welcome vue</p>
        </template>
    
        <script>
            var vm=new Vue({
                el:'#box',
                data:{
                    a:'aaa'
                },
                components:{
                    'aaa':{//标签名
                        template:'#aaa'//模版位置
                    }
                }
            });
    
        </script>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <script src="bower_components/vue/dist/vue.js"></script>
        <style>
        </style>
    </head>
    <body>
        <div id="box">
            <aaa>
                <ul slot="ul-slot">
                    <li>1111</li>
                    <li>2222</li>
                    <li>3333</li>
                </ul>
                <ol slot="ol-slot">
                    <li>111</li>
                    <li>222</li>
                    <li>333</li>
                </ol>
            </aaa>
            <hr>
            <aaa>
            </aaa>
        </div>
        <template id="aaa">
            <h1>xxxx</h1>
            <slot name="ol-slot">这是默认的情况</slot>
            <p>welcome vue</p>
            <slot name="ul-slot">这是默认的情况2</slot>
        </template>
    
        <script>
            var vm=new Vue({
                el:'#box',
                data:{
                    a:'aaa'
                },
                components:{
                    'aaa':{
                        template:'#aaa'
                    }
                }
            });
    
        </script>
    </body>
    </html>
  • 相关阅读:
    web service
    常用的正则表达式
    xml
    sql helper
    sql server 表连接
    asp.net页面生命周期
    创建简单的ajax对象
    checkbox选中问题
    ES6之扩展运算符 三个点(...)
    Object.assign()的用法 -- 用于将所有可枚举属性的值从一个或多个源对象复制到目标对象,返回目标对象
  • 原文地址:https://www.cnblogs.com/yaowen/p/6978973.html
Copyright © 2011-2022 走看看