【发布时间】:2020-12-11 21:31:29
【问题描述】:
我关注了https://www.npmjs.com/package/jsonpath。尝试了一种包含外部 js 文件的方法,但没有运气。
【问题讨论】:
我关注了https://www.npmjs.com/package/jsonpath。尝试了一种包含外部 js 文件的方法,但没有运气。
【问题讨论】:
import jsonPath 工作后 -
import * as jsonPath from 'jsonpath/jsonpath';
JsonPath 长毛绒也适用于JSONPath-plus,这与 Jsonpath 相同。我有以下对我有用的编码 sn-p-
安装 JSONPath-plus
npm install jsonpath-plus
angular.json 文件
"scripts": [
"node_modules/jsonpath-plus/dist/index-umd.js",
"src/assets/js/jsonpath.js"
]
jsonpath.js 有以下代码 -
function jsonPath() {
return JSONPath;
}
现在在 ts 文件中使用这个函数,像下面这样声明它 -
declare const jsonPath: any;
// use it like
jsonPath().JSONPath(path, json);
【讨论】: