JS_jsonp前端跨域处理_前端跨域如何处理

1.安装

npm install fetch-jsonp --save

2.导入

import fetchJsonp  from 'fetch-jsonp'

3.使用

fetchJsonp('http://',{
    
    
      method:'get'
    }).then(res=>{
    
    
      return res.json()
    }).then(data=>{
    
    			//请求成功
      console.log(data);  	//返回数据
    }).catch(error=>{
    
    		//请求失败

    })

猜你喜欢

转载自blog.csdn.net/weixin_44599931/article/details/107826761