2022-11-02 19:22:19 +08:00
|
|
|
<!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">
|
|
|
|
<apps></apps>
|
|
|
|
<button @click="Clickme()">点击我</button>
|
|
|
|
</div>
|
|
|
|
<template id="tpl">
|
|
|
|
<div>
|
|
|
|
<h1>这是子组件</h1>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</body>
|
2022-11-19 11:23:13 +08:00
|
|
|
<script src="../../../00-tools/JavaScript/vue.js"></script>
|
2022-11-02 19:22:19 +08:00
|
|
|
<script>
|
|
|
|
new Vue({
|
|
|
|
el:"#app",
|
|
|
|
methods: {
|
|
|
|
Clickme(){
|
|
|
|
this.$children[0].ChildItems()
|
|
|
|
for (let i =0;i<this.$children[0].list.length;i++){
|
|
|
|
this.$children[0].list[i]=i+2-1/2
|
|
|
|
}
|
|
|
|
console.log(this.$children[0].list);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components:{
|
|
|
|
'apps':{
|
|
|
|
template:"#tpl",
|
|
|
|
data(){
|
|
|
|
return{
|
|
|
|
list:[0,1,2,3,5,6,7,3,1]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
ChildItems(){
|
|
|
|
let item=1
|
|
|
|
console.log("这是子组件函数");
|
|
|
|
console.log(this.list);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
</html>
|