码迷,mamicode.com
首页 > 其他好文 > 详细

组件命名约定

时间:2017-10-28 18:46:32      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:camel   定义   技术   color   大写   png   驼峰   rip   注意   

<body>
    <div id="app">
        <kebab-cased-component></kebab-cased-component>
        <camel-cased-component></camel-cased-component>
        <pascal-cased-component></pascal-cased-component>
    </div>
    <script>
        //组件命名约定
        new Vue({
            el:‘#app‘,
            components:{
                ‘kebab-cased-component‘:{ template:‘<div>kebab-cased-component</div>‘ },
                ‘camelCasedComponent‘:{ template:‘<div>camelCasedComponent</div>‘ },
                ‘PascalCasedComponent‘:{ template:‘<div>PascalCasedComponent</div>‘}
            }
        })
        //渲染结果:
        技术分享
        //结论:HTML中都需要用到短横杠写法,组建中可以使用短横杠或者驼峰或者首字母大写,注意components里面的属性都是用字符串,我们继续往下看
        
    </script>
</body>

 

<body>
    <div id="app">
        <kebab-cased-component></kebab-cased-component>

        <camel-cased-component></camel-cased-component>
        <camelCasedComponent></camelCasedComponent>

        <pascal-cased-component></pascal-cased-component>
        <pascalCasedComponent></pascalCasedComponent>
        <PascalCasedComponent></PascalCasedComponent>
    </div>
    <script>
         new Vue({
             el:‘#app‘,
             components:{
                 ‘kebab-cased-component‘:{ template:‘<div>kebab-cased-component</div>‘ },
                ‘camelCasedComponent‘:{ template:‘<div>camelCasedComponent</div>‘ },
                ‘PascalCasedComponent‘:{ template:‘<div>PascalCasedComponent</div>‘}
             }
         })
         技术分享
      **看到这里,你会发现凡是用字符串作为components属性的,HTML都只能用短横杠自定义标签,接着往下看**
</script> </body>
<body>
    <div id="app">
        <kebab-cased-component></kebab-cased-component>

        <camel-cased-component></camel-cased-component>
        <camelCasedComponent></camelCasedComponent>

        <pascal-cased-component></pascal-cased-component>
        <pascalCasedComponent></pascalCasedComponent>
        <PascalCasedComponent></PascalCasedComponent>
    </div>
    <script>
         new Vue({
             el:‘#app‘,
             components:{
                 ‘kebab-cased-component‘:{ template:‘<div>kebab-cased-component</div>‘ },
                camelCasedComponent:{ template:‘<div>camelCasedComponent</div>‘ },
                PascalCasedComponent:{ template:‘<div>PascalCasedComponent</div>‘}
             }
         })
    </script>
</body>

可恶,不知道哪里写错了,竟然没有符合预期,让我再研究研究

技术分享

组件命名约定

标签:camel   定义   技术   color   大写   png   驼峰   rip   注意   

原文地址:http://www.cnblogs.com/ItIsInteresting/p/7747455.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!