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