1
使用Pbiviz開發自定義Power Bi視覺效果時可能會導致$ is not a function
錯誤?
當我想指定jquery插件時會出現問題。看起來像錯誤的庫命令,但輸出文件有適當的一個。
tsconfig.json:
{
"compilerOptions": {
"allowJs": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "ES5",
"sourceMap": true,
"out": "./.tmp/build/visual.js"
},
"files": [
".api/v1.7.0/PowerBI-visuals.d.ts",
"src/settings.ts",
"src/visual.ts",
"node_modules/@types/jquery/index.d.ts",
"node_modules/@types/datatables.net/index.d.ts",
"node_modules/@types/lodash/index.d.ts",
"node_modules/powerbi-visuals-utils-dataviewutils/lib/index.d.ts"
]
}
pbiviz.json:
"externalJS": [
"node_modules/powerbi-visuals-utils-dataviewutils/lib/index.js",
"node_modules/jquery/dist/jquery.js",
"node_modules/datatables.net/js/jquery.dataTables.js",
"node_modules/lodash/lodash.min.js"
],
的package.json:
"dependencies": {
"@types/datatables.net": "^1.10.1",
"@types/jquery": "^2.0.48",
"@types/lodash": "^4.14.50",
"datatables.net": "^1.10.15",
"jquery": "^2.1.0",
"lodash": "^4.17.4",
"powerbi-visuals-utils-dataviewutils": "1.2.0"
},
錯誤:
Uncaught TypeError: $ is not a function
at <anonymous>:14820:21
at <anonymous>:10387:3
at Window.<anonymous> (<anonymous>:10390:1)
at <anonymous>:25969:20
at Object.r [as injectJsCode] (visualhostcore.min.js:2)
at i.loadWithoutResourcePackage (visualsandbox.min.js:1)
at i.executeMessage (visualsandbox.min.js:1)
at i.onMessageReceived (visualsandbox.min.js:1)
at visualsandbox.min.js:1
at e.invokeHandler (visualhostcore.min.js:2)