Vue介绍中的todo-item组件无法显示问题

在Vue官方文档的介绍部分,todo-item组件无法显示出来,需要在script部分增加以下代码:

var vm = new Vue({
        el: 'todo-item'
    });

完整的代码如下所示:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Learning Vue!</title>
    <script src="https://unpkg.com/vue"></script>
</head>
<body>
    <ol>
        <todo-item></todo-item>
    </ol>

    <script>
        Vue.component('todo-item', {
            template: '<li>这是个待办事项</li>'
        });

        var vm = new Vue({
            el: 'todo-item'
        });
    </script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/yanzel/article/details/75729822