template的兩種寫法
<!DOCTYPE html>
<html lang="en">
<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></title>
<!-- vue.min.js -->
<script src="./js/vue.min.js"></script>
</head>
<body>
<!-- dom -->
<div id="app">
<my-component1></my-component1>
</div>
<!-- 模板寫法1 -->
<template id="tmpl1">
<h1>我是模板寫法1</h1>
</template>
<!-- 模板寫法2 -->
<script type="text/html" id="tmpl2">
<h1>我是模板寫法2</h1>
</script>
<script>
// 創(chuàng)建vue實(shí)例
new Vue({
el: '#app',
data: {},
components: { // 注冊局部組件
'my-component1': {
template: `#tmpl2`
}
}
})
</script>
</body>
</html>