fix: 解决过滤器的错误处理

This commit is contained in:
奔跑的面条
2022-07-06 20:14:41 +08:00
parent 4ba3d8803a
commit 74e30390cf
4 changed files with 8 additions and 15 deletions
+3 -3
View File
@@ -5,7 +5,7 @@ import throttle from 'lodash/throttle'
import Image_404 from '../assets/images/exception/image-404.png'
import html2canvas from 'html2canvas'
import { downloadByA } from './file'
import { isString } from './type'
import { toString } from './type'
import cloneDeep from 'lodash/cloneDeep';
/**
@@ -196,7 +196,7 @@ export const canvasCut = (html: HTMLElement | null, callback?: Function) => {
export const newFunctionHandle = (
data: any,
funcStr?: string,
toString?: boolean,
isToString?: boolean,
errorCallBack?: Function,
successCallBack?: Function
) => {
@@ -204,7 +204,7 @@ export const newFunctionHandle = (
if (!funcStr) return data
const fn = new Function('data', funcStr)
const fnRes = fn( cloneDeep(data))
const resHandle = toString && isString(fnRes) ? fnRes : JSON.stringify(fnRes)
const resHandle = isToString ? toString(fnRes) : fnRes
// 成功回调
successCallBack && successCallBack(resHandle)
return resHandle