瀏覽代碼

产品详情中数据解析增加调试功能,并处理兼容报错的情况

yanglzh 2 年之前
父節點
當前提交
0c00803f98
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/views/iot/device/product/component/dataParse.vue

+ 2 - 2
src/views/iot/device/product/component/dataParse.vue

@@ -72,10 +72,10 @@ function mock() {
 		const fun = eval("(" + funStr + ")")
 		try {
 			const res = fun(JSON.parse(inputData.value))
-			outputData.value = JSON.stringify(res, null, 2)
+			outputData.value = typeof res === 'object' ? JSON.stringify(res, null, 2) : res
 		} catch {
 			const res = fun(inputData.value)
-			outputData.value = JSON.stringify(res, null, 2)
+			outputData.value = typeof res === 'object' ? JSON.stringify(res, null, 2) : res
 		}
 	} catch (error) {
 		ElMessage.error('数据解析脚本语法校验未通过或参数类型有误')