当前位置: 首页 > news >正文

网站建设 面试题找客户资源的网站

网站建设 面试题,找客户资源的网站,公司网站建设需要资质,网站建设中国十强1、axios调接口特殊字符丢失的问题 项目开发过程中遇到一个接口传参#xff0c;参数带特殊字符#xff0c;axios调接口特殊字符丢失的问题 例如接口#xff1a; get/user/detail/{name} name是个参数直接调接口的时候拼到接口上#xff0c;get/user/detail/test123#$%参数带特殊字符axios调接口特殊字符丢失的问题 例如接口 get/user/detail/{name} name是个参数直接调接口的时候拼到接口上get/user/detail/test123#$%调接口发现后面的特殊字符#$%丢失了调的接口变成了get/user/detail/test123 2、解决办法 参数使用encodeURIComponent编译一下再拼到接口上这样特殊字符不会丢失后端可以正常接收参数。 import Axios from src/axios/index.js;const name test123#$%;// 直接拼接口上 Axios.get(get/user/detail/${name}).then(function (response) {console.log(response); }).catch(function (error) {console.log(error); });// 参数使用encodeURIComponent编译一下,再拼接口上 Axios.get(get/user/detail/${encodeURIComponent(name)}).then(function (response) {console.log(response); }).catch(function (error) {console.log(error); }); // 直接拼接口上 // 参数使用encodeURIComponent编译一下,再拼接口上 3、延伸 使用params传参如果直接将参数使用拼接到后面也是会存在特殊字符丢失的问题 import Axios from src/axios/index.js; const name test123#$%;// 直接拼接口上 Axios({url: get/user/detail?name${name},method: get, }).then(function (response) {console.log(response); }).catch(function (error) {console.log(error); });// 参数使用encodeURIComponent编译一下,再拼接口上 Axios({url: get/user/detail?name${encodeURIComponent(name)},method: get, }).then(function (response) {console.log(response); }).catch(function (error) {console.log(error); });// 正常逻辑传参数推荐 Axios({url: get/user/detail,method: get,params: { name }, }).then(function (response) {console.log(response); }).catch(function (error) {console.log(error); }); // 直接拼接口上 // 参数使用encodeURIComponent编译一下,再拼接口上 // 正常逻辑传参数推荐 4、encodeURI 和 encodeURIComponent MDN上关于encodeURI 和 encodeURIComponent的介绍 encodeURI() - JavaScript | MDN encodeURIComponent() - JavaScript | MDN encodeURIComponent不转义的字符包括 类型包含非转义的字符字母 数字 - _ . ! ~ *  ( ) encodeURI不转义的字符包括 类型包含保留字符; , / ? :     $非转义的字符字母 数字 - _ . ! ~ *  ( )数字符号# 5、解码 encodeURI使用decodeURI解码encodeURIComponent使用decodeURIComponent 解码
http://icebutterfly214.com/news/56555/

相关文章:

  • Gephi怎样优化MySQL数据的展示效果
  • Fisrt Blog
  • STM32中断、NVIC、EXTI
  • 题解:AT_agc028_e [AGC028E] High Elements
  • Luogu P10778 BZOJ3569 DZY Loves Chinese II 题解 [ 紫 ] [ Xor Hashing ] [ 线性基 ] [ DFS 树 ]
  • .NET+AI | MEAI | Function Calling 基础(3)
  • NCHU-23207335-面向对象程序设计-BLOG-1
  • 开发智联笔记项目时所遇问题(4)
  • 卡码网94: bellman_ford算法
  • day11-Dify智能体-发布-工作流
  • 2025年热门的成都打印机行业内知名租赁公司排行榜
  • 深入解析:深度学习——Logistic回归中的梯度下降法
  • 详细介绍:压缩与缓存调优实战指南:从0到1根治性能瓶颈(四)
  • 完整教程:【人工智能】神经网络的优化器optimizer(四):Adam自适应动量优化器
  • 让 Maven 能找到本地 JAR 而无需把它上传到公共仓库:
  • Windows Server 2019 中文版、英文版下载 (2025 年 11 月更新)
  • 2025年包头家政服务标杆企业最新推荐:信达家政,保洁|保姆|开荒|月嫂|护工一体化服务新标准
  • markdown的初级使用教程
  • 浙江初中生数学提分老师怎么选?适配杭州、宁波、绍兴、温州学生
  • 2025 年 11 月羊绒衫厂家推荐排行榜,女式羊绒衫,男士羊绒衫,小香风羊绒衫,精选优质羊绒衫公司推荐
  • 【重磅】2025两院院士增选揭晓:144位顶尖专家入选,AI、芯片与量子技术成最大赢家!
  • 留学中介排名TOP10服务体验评选,这家学生最满意
  • 2025年度少儿编程教育机构权威评测:科学体系与竞赛成果双轨制分析
  • 2025年电磁采暖炉品牌厂商权威推荐榜单:电磁感应采暖炉/节能电磁采暖炉/高频电磁采暖炉设备源头厂家精选
  • 2025年双P淋膜防漏杯定制厂家权威推荐榜单:隔热瓦楞杯/双层套筒纸杯/斜口薯条杯源头厂家精选
  • 江苏抗17级台风抗风卷帘门厂家排名怎么选
  • 江苏抗17级台风抗风卷帘门厂家排名前十哪家靠谱
  • 上海有哪些AI企业值得投资?行业发展与企业实力解析
  • Luogu P6893 [ICPC 2014 WF] Buffed Buffet 题解
  • 徐州一对一辅导机构哪个好?2026最新家教平台TOP5权威测评!精准提分数据溯源