1.组件模板的抽离
1.1 代码
<!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>
</head>
<body>
<div id="app">
<itembox></itembox>
</div>
<!-- 把template模板抽离出来 -->
<template id="myTem">
<div>
<h3>Vue学习</h3>
<p>Web前端开发</p>
</div>
</template>
<script src="./js/vue.js"></script>
<script>
Vue.component("itembox",{
template:"#myTem"
});
var vm=new Vue({
el:'#app',
data:{
},
methods:{
}
});
</script>
</body>
</html>