1.後端python django**:
獲取到的資料型別為字串(str)
host_list_json = json.loads(host_list_json) #
將字串資料轉成json型別
')2.前端html vue**
doctype html根據後端返回的資料字段取資訊>
<
html
lang
="en"
>
<
head
>
<
meta
charset
="utf-8"
>
<
title
>index
title
>
<
script
src="static/js/vue.js"
>
script
>
<
script
src="static/js/axios.min.js"
>
script
>
head
>
<
body
>
<
div
id="get_host_data"
>
<
button
@click
="gethostdata"
>獲取資料
button
>
<
table
class
="table table-bordered table-hover table-striped"
>
<
thead
>
<
tr>
<
td>id
td>
<
td>版本包
td>
<
td>md5
td>
tr>
thead
>
<
tbody
>
<
tr v-for
="(item, index) of host_list"
:key
="item.pk"
>
<
td>}
td>
<
td>}
td>
<
td>}
td>
tr>
tbody
>
table
>
div>
<
script
>
newvue(,
methods:
else})}
},mounted:
function
() })
script
>
body
>
html
>
vue專案使用axios請求後端資料
在專案中使用到的向後端請求和提交資料的方式,axios請求 在使用axios時,需要先安裝axios npm install axios安裝完成後在main.js中引入 import axios from axios 為了使用方便在定義為全域性方法 vue.prototype.http axios完...
vue中使用axios呼叫後端介面
vue本身不支援ajax介面的請求,所以在vue中經常使用axios這個介面請求工具。axios的官方github 在工程中的src目錄下新建乙個名為api的目錄,在src api目錄下新建乙個index.js檔案。在index.js裡面,編寫如下內容 繫結api index.js檔案,新增如下內容...
vue 使用axios 學習
1 axios的說明 參見 2 axios的使用 1 通過建立config.js配置檔案來設定 axiosl基本的路徑和引數 const baseurl 網域名稱 const config 新增一些其他的統一路徑 export default config 2 建立乙個http.js import ...