vue中jsonp插件的使用方法示例
通過jsonp簡單獲取接口數(shù)據(jù),對了,注意下jsonp方法會自動添加callback
<template><div class='sky'><h3>獲取城市:</h3><div class='skycon'></div></div></template><script>//導(dǎo)入jsonp插件import jsonp from ’jsonp’;export default{data(){return {}},created(){//jsonp請求數(shù)據(jù)this.getLocation()},methods:{getLocation(){let url = 'https://apis.map.qq.com/ws/location/v1/ip?key=CAABZ-AVSAQ-RDR5L-GTBDJ-HLA4O-A5FDB&output=jsonp&_=1599182599164'//jsonp方法會自動添加callbackjsonp(url,{},(err,data)=>{//url地址 //{}參數(shù) //(err,data)錯誤信息,獲取的數(shù)據(jù)console.log(data)})}}}</script><style></style>
總結(jié)
到此這篇關(guān)于vue中jsonp插件的使用的文章就介紹到這了,更多相關(guān)vue中jsonp插件使用內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
