網(wǎng)站首頁 編程語言 正文
我在本地開發(fā)了一個(gè)分頁的接口
這里 我設(shè)置的是 form-data 參數(shù)類型
要的是個(gè)表單類型的數(shù)據(jù) 然后呢 我按傳統(tǒng)PC端的方式處理了數(shù)據(jù)
<template>
<view class = "box">
<view class="management"></view>
</view>
</template>
<script>
export default {
data() {
return {
page: 1,
pageSize: 3
}
},
mounted() {
let data = new FormData();
console.log(this.page);
data.append("page", this.page);
data.append("pageSize", this.pageSize);
console.log(data);
uni.request({
url: '/books/page',
method: 'GET',
data: data,
header: {
"content-type": "multipart/form-data",
},
success: (res) => {
console.log(res.data);
},
fail: (err) => {
console.log(err);
},
})
}
}
</script>
<style scoped>
.box{
height: 50vh;
width: 100vw;
}
.management{
width: 100vw;
height: 33%;
border-bottom: 1px solid black;
}
</style>
但是這樣 運(yùn)行起項(xiàng)目
他連請求都沒法出去
渲染 uni中使用FormData是有問題的
我直接將代碼改成
<template>
<view class = "box">
<view class="management"></view>
</view>
</template>
<script>
export default {
data() {
return {
page: 1,
pageSize: 3
}
},
mounted() {
uni.request({
url: '/books/page',
method: 'GET',
data: {
page: this.page,
pageSize: this.pageSize
},
header: {
"content-type": "application/x-www-form-urlencoded",
},
success: (res) => {
console.log(res.data);
},
fail: (err) => {
console.log(err);
},
})
}
}
</script>
<style scoped>
.box{
height: 50vh;
width: 100vw;
}
.management{
width: 100vw;
height: 33%;
border-bottom: 1px solid black;
}
</style>
我們數(shù)據(jù)就還是給JSON data
只需要在 header 中加上 “content-type”: “application/x-www-form-urlencoded”,
我們運(yùn)行代碼 他就成一個(gè)表單類型的數(shù)據(jù)了
數(shù)據(jù)也成功的請求回來了
原文鏈接:https://blog.csdn.net/weixin_45966674/article/details/131446045
- 上一篇:沒有了
- 下一篇:沒有了
相關(guān)推薦
- 2022-06-01 詳解Python中sorted()和sort()的使用與區(qū)別_python
- 2023-10-14 【c++】四舍五入
- 2023-04-24 Python?相對路徑報(bào)錯(cuò):"No?such?file?or?directory"'原因及解決方法_
- 2022-06-08 問題記錄:HttpServletRequestWrapper導(dǎo)致跨域失敗的問題
- 2023-07-09 時(shí)間模式更改為:“剛剛“,“分鐘前“,“小時(shí)前“
- 2022-11-21 初識Golang?Mutex互斥鎖的使用_Golang
- 2022-08-17 WPF中的導(dǎo)航框架概述_C#教程
- 2022-10-20 Python中使用Frozenset對象的案例詳解_python
- 欄目分類
-
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支