vue的一个小疑惑

vue 模板语法是这样的:

html:
<div id='app'>
    <!-- 调用该组件之前必须先注册该组件! -->
    <test></test>
</div>

js:
new Vue({
    components: {
        // 注册 test 组件
        test: {
            template: '<div class="test">我是 test 组建内容!</div>'
        }
    }
});

上面的应该一看秒懂。你看不懂的是使用了ES6+(含)语法的代码:

// 组件
let App = {
    template: '<div>欢迎使用!</div>'
}:

new Vue({
    // template 渲染的 html
    // 这跟上面是一样的,必须先注册 App 组件
    // 然后在模板中引用
    // <App /> 是简写形式,等价于 <App></App>
    template: '<App />'
    components: {
        // es6 语法, 键名和变量名一致
        App
    }
});
原文地址:https://www.cnblogs.com/yxyc/p/14669430.html