效果图
1.HTML结构
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
</div>
<div id="app1">
</div>
<div id="app2">
</div>
</body>
</html>
2.vue.js
<script src="./js/vue.min.js"></script>
3.vue组件定义
<script>
var cpn = Vue.extend({
template:'<p> I wish U {{text1}}<HR></p>',
data:function(){
return{
text1:'happiness',
text2:'health',
text3:'good luck'
}
}
});
var cpn1 = Vue.extend({
template:'<p> I wish U {{text2}}<HR></p>',
data:function(){
return{
text1:'happiness',
text2:'health',
text3:'good luck'
}
}
});
var cpn2 = Vue.extend({
template:'<p> I wish U {{text3}}<HR></p>',
data:function(){
return{
text1:'happiness',
text2:'health',
text3:'good luck'
}
}
});
4.挂载
new cpn().$mount('#app')
new cpn1().$mount('#app1')
new cpn2().$mount('#app2')
</script>
</body>
</html>