Skip to content

Commit f321343

Browse files
committed
fix some typos
1 parent 215ff05 commit f321343

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

mock/utils.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
* @returns {Object}
44
*/
55
function param2Obj(url) {
6-
const search = url.split('?')[1]
6+
const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
77
if (!search) {
88
return {}
99
}
10-
return JSON.parse(
11-
'{"' +
12-
decodeURIComponent(search)
13-
.replace(/"/g, '\\"')
14-
.replace(/&/g, '","')
15-
.replace(/=/g, '":"')
16-
.replace(/\+/g, ' ') +
17-
'"}'
18-
)
10+
const obj = {}
11+
const searchArr = search.split('&')
12+
searchArr.forEach(v => {
13+
const index = v.indexOf('=')
14+
if (index !== -1) {
15+
const name = v.substring(0, index)
16+
const val = v.substring(index + 1, v.length)
17+
obj[name] = val
18+
}
19+
})
20+
return obj
1921
}
2022

2123
/**

vue.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = {
5353
// config.plugins.delete('preload')
5454

5555
// when there are many pages, it will cause too many meaningless requests
56-
config.plugins.delete('prefetch') //
56+
config.plugins.delete('prefetch')
5757

5858
// set svg-sprite-loader
5959
config.module

0 commit comments

Comments
 (0)