在父组件里面引入子组件
<template>
<view class="content">
<!-- 在页面进行引入(注意:这里是中文,所以是“‘’”引号) -->
<mo-ban :han="'我是小涵涵'"></mo-ban>
</view>
</template>
import moBan from '@/pages/moBan/moBan';
export default {
components: {
moBan
}
}
子组件moBan.vue
<template>
<view>
<!-- 把传递过来的参数进行页面渲染 -->
<text>我是引用模板中的文字的小憨憨{
{
han }}</text>
</view>
</template>
<script>
export default {
props: {
//接受父元素传过来的参数
han: {
type: String,
required: true
}
}
};
</script>