父组件 ( 正常引入调用 )文章来源:https://www.toymoban.com/news/detail-597848.html
<template>
<div>
<moduleSun :chartData="item" v-for="(item,index) in chartData" :key="index" />
</div>
</template>
<script>
import moduleSun from '@/views/moduleSun'
export default {
components: { moduleSun },
data() {
return {
chartData: [{
nameCN: '111',
nameEN: 'en111',
remarks: '我是111',
children: [{
nameCN: '222',
nameEN: 'en222',
remarks: '我是222',
children: [{
nameCN: '222-111',
nameEN: 'en222-111',
remarks: '我是222-111',
}],
}, {
nameCN: '333',
nameEN: 'en333',
remarks: '我是333',
}],
}],
}
},
}
</script>
子组件 ( 组件中需定义name名称 )文章来源地址https://www.toymoban.com/news/detail-597848.html
<template>
<div class="chart-layout">
<div class="chart-main">
<div>{{chartData.nameCN}}</div>
<div class="chart-en">{{chartData.nameEN}}</div>
<div class="chart-remarks">{{chartData.remarks}}</div>
</div>
<moduleSun :chartData="item" v-for="(item,index) in chartData.children" :key="index" />
</div>
</template>
<script>
export default {
name: 'moduleSun',
props: {
chartData: {
type: Object,
default: () => {
return {}
}
},
},
}
</script>
<style lang="less" scoped>
.chart-main {
width: 100px;
border: 1px solid #000;
> div {
margin-top: 5px;
}
}
</style>
到了这里,关于VUE 组件中自己调用自己的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!