【发布时间】:2020-05-11 16:26:40
【问题描述】:
我的 Vue 应用程序中有一个 axios 调用失败:
axios.get(`parts/${item.number}`)
.then(response => { /* do things */ });
...因为有时item.number 包含/ ...在 URL 中包含这些内容并不好。对item.number 进行 HTML 编码的推荐方法是什么?
【问题讨论】:
-
推荐的方式是使用
encodeURIComponent,顾名思义。这取决于后端如何处理 url。