Skip to content

Commit

Permalink
vue2do-9: 优化工具函数
Browse files Browse the repository at this point in the history
  • Loading branch information
zen0822 committed Nov 30, 2018
1 parent f8b8bba commit f5d3462
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/util/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const ajax = ({
let param = formatParam(data)

let urlGettenParam = formatParam(gettenData)
const timeStamp = cache ? '' : `t=${new Date().getTime()}&${urlGettenParam}`
const timeStamp = cache ? '' : `t=${new Date().getTime()}${urlGettenParam ? `&${urlGettenParam}` : ''}`

if (contentType) {
if (contentType.includes('text/plain') || contentType.includes('application/json')) {
Expand Down
8 changes: 4 additions & 4 deletions src/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
const debounce = (func, wait = 1000) => {
let timeout = null

const debounced = (args) => {
const debounced = (...args) => {
clearTimeout(timeout)

timeout = setTimeout(() => {
func(args)
func.apply(null, args)
}, wait)
}

Expand All @@ -39,13 +39,13 @@ const debounce = (func, wait = 1000) => {
const throttle = (func, wait = 1000) => {
let startTime = Date.now()

const throttled = () => {
const throttled = (...args) => {
let time = Date.now()

if (startTime + wait - time <= 0) {
startTime = time

return func()
return func.apply(null, args)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const search = (urlSearch) => {
const fitSearch = (urlSearch) => {
const urlSearchObj = search(urlSearch)
const urlSearchObjKeys = Object.keys(urlSearchObj)
const urlSearchObjValues = Object.keys(urlSearchObj)
const urlSearchObjValues = Object.values(urlSearchObj)
let urlSearchArr = []

urlSearchObjValues.forEach((item, index) => {
Expand Down

0 comments on commit f5d3462

Please sign in to comment.