代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>组件2</title>
<script src="../lib/vue.js"></script>
</head>
<body>
<div id="app">
{{msg}}
<co-m1></co-m1>
<com2></com2>
<com3></com3>
</div>
<template id="temp1">
<div>
<h1>这是外部定义的组件com1</h1>
</div>
</template>
<template id="temp2">
<div>
<h1>这是内部定义的组件com2</h1>
<h2>{{msg2}}</h2>
</div>
</template>
<template id="temp3">
<div>
<h1>这是组件三com3</h1>
<button @click="increment()">plus one</button>
<h2>{{count}}</h2>
</div>
</template>
</body>
<script>
Vue.component("CoM1",{
template:'#temp1'
})
let vm = new Vue({
el:"#app",
data:{
msg:'你好'
},
method:{
},
components:{
com2:{
template:'#temp2',
data:function(){
return {
msg2:'这是组件中的data'
}
}
},
com3:{
template:"#temp3",
data:function(){
return{
count:1
}
},
methods:{
increment(){
this.count++
}
}
}
}
})
</script>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。