1 Star 0 Fork 0

prcool/前端开发学习

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
组件2.html 1.43 KB
一键复制 编辑 原始数据 按行查看 历史
prcool 提交于 2021-09-11 21:02 +08:00 . 前端开发学习
<!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>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/prcool/front-end-development-learning.git
git@gitee.com:prcool/front-end-development-learning.git
prcool
front-end-development-learning
前端开发学习
master

搜索帮助