vue component为什么不显示?

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>Document</title>

</head>

<body>

    <ol>

        <!-- 创建一个 todo-item 组件的实例 -->

        <todo-item></todo-item>

    </ol>


    <script src="https://unpkg.com/vue"></script>

    <script>

        Vue.component('todo-item', {

            template: '<li>这是个待办项</li>'

        })

    </script>

</body>

</html>

初学vue,为什么我这边显示的是一个空白页面,组件模板的写法是错的么?

HUWWW
浏览 467回答 1
1回答

jeck猫

html里面是这样的<div id='app'><v-header></v-header></div>js 是这样的&nbsp; &nbsp; Vue.component('vHeader', {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; template: '<div>A custom component!</div>'&nbsp; &nbsp; &nbsp; &nbsp; })&nbsp; &nbsp; new Vue({&nbsp; &nbsp; &nbsp; &nbsp; el:'#app',&nbsp; &nbsp; })
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript