1 父页面调用assets-trend子组件,并接受assets-trend子组件传来的参数
<assets-trend style="flex: 2.7">
<template slot-scope="slot">
{{slot.slotMsg}}
</template>
</assets-trend>
2 子页面assets-trend使用slot传值
<div>
<template slot="title-tool">
<slot slotMsg="这是子页面的信息"></slot>
</template>
</div>
使用方法2-1
父页面填写在子页面显示的内容,标识为asdf,调用子组件el-search
<el-search>
<template slot="asdf">
<el-form-item>
<el-input placeholder="子页面显示的内容"/>
</el-form-item>
</template>
</el-search>
子组件中渲染父页面内容的方式
<template v-if="">
<slot name="asdf"></slot>
</<template>
使用方法2
父页面调用子页面el-search,子页面渲染出父页面的内容
其中needShowParentContent父页面和子页面要一致
<el-search :col-span="8" labelPosition="right" is-fold :form="queryParams" :searchJson="searchJson" @search="handleQuery" @reset="resetQuery">
<template slot="needShowParentContent">
<el-date-picker
type="year"
v-model="queryParams.bonusYear"
format="yyyy"
size="mini"
value-format="yyyy"
:style="{ width: '100px' }"
placeholder="请选择"
clearable>
</el-date-picker>
或者
<template v-slot:ssss="needShowParentContent">
<el-date-picker
type="year"
v-model="queryParams.bonusYear"
format="yyyy"
size="mini"
value-format="yyyy"
:style="{ width: '100px' }"
placeholder="请选择"
clearable>
</el-date-picker>
</template>
</el-search>
父页面定义展示的变量的参数
searchJson: [
{
name: 'workDetail',
label: '工作事项',
type: 'text'
},
{
name: 'ssss',
label: '测试',
type: 'slot'
}
],
子页面接受
循环父页面的searchJson
。。。。。
<template>
<slot :name="field.name" :needShowParentContent="field"></slot>
</template>
。。。。
效果
使用方法3
父页面使用child组件
<child>
<template v-slot:proposalName="slotData">
<el-button size="mini" type="text" @click="viewMotion(slotData.slotData)">{{slotData.slotData.motionName}}</el-button>
</template>
</child>
子页面展示父页面的dom数据,但是值用的子页面的值
<el-table>
<el-table-column label="名称" prop="motionName">
<template slot-scope="scope">
<slot name="proposalName" :slotData="scope.row"></slot>
</template>
</el-table-column>
</el-table>