问题描述
有两种使用第三方库(BrowserPrint.js)的环境;
There are two environments which using the 3rd party library (BrowserPrint.js);
-
工作环境-JS和jQuery在文档的
<head>
部分中仅包含3party库的地方
WORKING ENV - JS and jQuerywhere 3party libraries are included simply in the
<head>
part of the document
并且主函数在
$(document).ready(setup_web_print);
不使用环境-Angular,JS和jQuery
NOT WORKING ENV - Angular, JS and jQuery
其中第三方库包含在组件中:
where 3rd party libraries are included in component:
import * as $ from 'jquery';
import * as bp from '../../../content/js/BrowserPrint-1.0.4.js';
并在ngOnInit()
生命周期挂钩中触发:
and triggered in ngOnInit()
lifecycle hook:
ngOnInit() {
$(document).ready(function () {
...
})
...
}
控制台出现错误
ReferenceError: finishedFunction is not defined
at Object.t.getDefaultDevice (BrowserPrint-1.0.4.js:95)
因此它似乎无法访问finishedFunction
var a = n("GET", e("available"));
a && (finishedFunction = function(e) {
response = e, response = JSON.parse(response);
for (var n in response)
if (response.hasOwnProperty(n) && response[n].constructor === Array) {
arr = response[n];
for (var i = 0; i < arr.length; ++i) arr[i] = new t.Device(arr[i])
}
return void 0 == o ? void r(response) : void r(response[o])
}, i(void 0, a, finishedFunction, s), a.send())
有人知道如何解决此问题,为什么在第二个env中不起作用?
Does anybody know how to fix this and why doesn't work with in second env?
推荐答案
我真的不知道JavaScript是如何处理此逗号编写的代码的.但是我认为这就是您想要的,不是吗?
I really don't know how JavaScript is handling this comma-written code. But I think this is what you want, isn't it?
if(a) {
var finishedFunction = function(e) {
if (response = e, "" == response) return void s(null);
response = JSON.parse(response);
var n = new t.Device(response);
s(n)
};
i(void 0, a, finishedFunction, o);
a.send();
}
这篇关于无法访问匿名功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!