用template标签构建组件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue组件</title>
<script src="js/vue.js"></script>
</head>
<body>
<div id="app1">
<my-com></my-com>
</div>
<template id="myCom">
<div>这是template标签构建的组件</div>
</template>
<script>
//全局注册组件------------------------------------------------------------------
Vue.component('my-com',{
template: '#myCom'
});
var app1 = new Vue({
el: '#app1'
});
//局部注册组件--------------------------------------------------------------
var app1 = new Vue({
el: '#app1',
components:{
'my-com':{
template: '#myCom'
}
}
});
</script>
</body>
</html>