vue中jsonp插件的使用方法示例
通過(guò)jsonp簡(jiǎn)單獲取接口數(shù)據(jù),對(duì)了,注意下jsonp方法會(huì)自動(dòng)添加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請(qǐng)求數(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方法會(huì)自動(dòng)添加callbackjsonp(url,{},(err,data)=>{//url地址 //{}參數(shù) //(err,data)錯(cuò)誤信息,獲取的數(shù)據(jù)console.log(data)})}}}</script><style></style>
總結(jié)
到此這篇關(guān)于vue中jsonp插件的使用的文章就介紹到這了,更多相關(guān)vue中jsonp插件使用內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. 理解PHP5中static和const關(guān)鍵字2. Android table布局開(kāi)發(fā)實(shí)現(xiàn)簡(jiǎn)單計(jì)算器3. jQuery 實(shí)現(xiàn)DOM元素拖拽交換位置的實(shí)例代碼4. IntelliJ IDEA安裝插件的方法步驟5. php模擬實(shí)現(xiàn)斗地主發(fā)牌6. vue 使用localstorage實(shí)現(xiàn)面包屑的操作7. Vue封裝一個(gè)TodoList的案例與瀏覽器本地緩存的應(yīng)用實(shí)現(xiàn)8. Python random庫(kù)使用方法及異常處理方案9. .Net Core使用Coravel實(shí)現(xiàn)任務(wù)調(diào)度的完整步驟10. Vuex localStorage的具體使用

網(wǎng)公網(wǎng)安備