在vue前端开发时,我们都有统一定义了request来get或post请求,一般情况下我们的Content-Type都是application/x-www-form-urlencoded,那如何用其它方式呢比如JSON。代码如下
1、application/json方式
export async function exportToExcelReport(data) {
return request("/exportToExcelReport", "post", data,{headers: { 'Content-Type':'application/json' }})
}
2、application/x-www-form-urlencoded方式
export async function simStatus(data) {
return request("/apiStatus", "post", qs.stringify(data), { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
}
注意要安装qs来序列号
import qs from 'qs'
vue配置.env .development变量
JSON字符串转换JSON对象
vue前端excel上传读取组件upload-excel-component
ui-element vue 报错 Prop being mutated: "placement"
Vue Error PostCss received undefined instead of CSS string