当加入标签比较多时,最好使用模板
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="js/vue1.0.js"></script>
</head>
<body>
<div id="example">
<my-component></my-component>
</div>
//template只是作为一个模板,其内容真实添加于div里面
<template id='aaa'>
<ul>
<li v-for='val in arr'>{{val}}</li>
</ul>
</template>
<script>
window.onload=function(){
new Vue({
el: '#example',
data:{
},
components:{
'my-component':{
data:function(){
return{
arr:['apple','pear','banana']
}
},
methods:{
},
template:'#aaa'
}
}
})
}
</script>
</body>
</html>