猿问

关于vue选项卡切换组件,使用同一个接口问题,求大家给点建议

我有一个vue技术问题问下各位。我有组件页面里面有个tab选项卡,分别是使用:is来动态切换组件,但是两者都是同一个请求接口,但我不想把两个组件都同时使用相同一个接口!请问该怎么优化好?大家给点建议,谢谢。
ps:(两个组件切换都用到上拉加载)。

SMILET
浏览 1018回答 2
2回答

慕尼黑8549860

把选项卡配置成数组,然后里面设置一些配置,动态组件传入对应的配置。[&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tabName:'选项卡一',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;options:{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;apiFunc:apiFunc1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//...&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}&nbsp; &nbsp; },&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tabName:'选项卡二',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;options:{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;apiFunc:apiFunc2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//...&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}&nbsp;&nbsp; &nbsp; }]<component :is="currentTab.tabName" :config="currentTab.options" />

天涯尽头无女友

没明白你的意思
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答