账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    react根据不同location引入不同的接口要怎么实现
    36
    0
    比如一个组件import {getData,getData1,getData2,...getData10} from '@/services/demo.ts'export default const DemoComponent = ()=>{ // 使用getData,getData1,getData2...}现在多个页面使用这一个组件,如何根据不同页面的路径,引入不同的servide,比如另一个页面import {getData,getData1,getData2,...getData10} from '@/service/demo2.ts'export default const DemoComponent = ()=>{ // 使用getData,getData1,getData2...}不同页面,只改接口文件的引入,比如只改demo.ts、demo2.t,例如if(location.path==='demo'){import {getData,getData1,getData2,...getData10} from '@/service/demo.ts'}else if(location.path==='demo2'){import {getData,getData1,getData2,...getData10} from '@/service/demo2.ts'}export default const DemoComponent = ()=>{ // 使用getData,getData1,getData2...}
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部