有一个页面,页面需要根据参数动态组合组件,最终形成展示. 示例
<template><!-- 企业信息 -->
<div>
<div v-for="(item,index) in corpInfoStepList" :id="item.names" :key="index" :ref="item.names">
<component :is="item.key" :ref="item.key" />
</div>
</div>
</template>
组合的组件都在corpInfoStepList
数组中.
现在有个需求:组件数组中:a,b请求同一个api地址(API.d)。希望把这个api的请求放到页面中进行(GET查询).以此达到减少网络请求的目地.
vue有什么机制实现. prop不在考虑之内:因为有的组件是不需要:API.d
page页面
a b内
新建一个 eventHub.js