我有一个与 Webpack 捆绑在一起的 React 应用程序。我想为我的一个组件使用网络工作者,它将数据导出为 Pdf。pdf 的生成可能需要一段时间并锁定浏览器,所以我想在 web worker 中完成这项工作,以便在单独的线程中完成。我遇到的问题是将 JsPDF 库导入到我的 Web Worker 脚本中,以便我可以使用它。
这是我的工作脚本:
import * as JsPDF from "jspdf";
export default () => {
self.addEventListener("message", event => {
const canvases = event.data;
const pdf = new JsPDF({
orientation: "l",
unit: "in",
});
// tslint:disable-next-line:prefer-for-of
for (let i = 0; i < canvases.length; i++) {
if (i > 0) pdf.addPage();
pdf.addImage(canvases[i].toDataURL("image/png"), "PNG", 0.25, 0, 11, 8);
}
pdf.save("report.pdf");
self.postMessage("done", "");
});
};
Run Code Online (Sandbox Code Playgroud)
这在运行时给了我这个错误:
Uncaught ReferenceError: jspdf__WEBPACK_IMPORTED_MODULE_0__ is not …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Ember Testing集成自动化测试.
应用程序在浏览器上运行正常,没有任何错误.我试过简单地跑步
ember test
Run Code Online (Sandbox Code Playgroud)
在命令行上,但得到一堆全局错误,所有测试都失败了.
这些是我得到的错误:
not ok 1 PhantomJS 2.1 - Global error: SyntaxError: Unexpected token ',' at http://localhost:4302/assets/vendor.js, line 145617
not ok 2 PhantomJS 2.1 - Global error: Error: Could not find module ember-metal/core required by: ember-testing/index at http://localhost:4302/assets/test-support.js, line 62
not ok 3 PhantomJS 2.1 - Global error: ReferenceError: Can't find variable: define at http://localhost:4302/assets/tests.js, line 1
...
Run Code Online (Sandbox Code Playgroud)
当我在浏览器上运行测试时,我没有得到语法错误(上面的第一个),第一个错误是
Uncaught Error: Could not find module `analogue/resolver` imported from `analogue/tests/helpers/resolver`
Run Code Online (Sandbox Code Playgroud)
这些对我来说没有意义,因为我不应该编辑vendor.js和它说它找不到的模块.有任何想法吗?
我想在我的Windows 7机器上设置一个开发环境,这样我就可以创建一个spring-boot应用程序.但是,我很难在Windows上安装Spring-boot.
这就是我到目前为止所做的:-Downloaded spring-boot CLI zip包并在C盘中解压缩-JAVA_HOME变量设置为c:\ Program Files(x86)\ Java\jdk1.6.0_14 -SPRING_HOME变量设置为C:\ spring-1.3.0.BUILD-SNAPSHOT - 为PATH环境变量添加了SPRING_HOME/bin
它说要添加符号链接到自动完成脚本,但我不知道如何做到这一点.毫不奇怪,当我用"spring --version"命令测试安装时,它失败了.
以前有人这样做过吗?
谢谢!
我正在使用IronPython 2.5(在TIBCO Spotfire内部)并且想要解析json文件.
此版本的IronPython中没有json库.simplejson也不起作用.我可以使用另一个库吗?它可以是.Net或Python,无所谓.
提前致谢!
我在我的ember应用程序中创建了一个名为ticket-stats的模型:
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
export default Model.extend({
get_tickets_more: attr(),
get_tickets: attr(),
get_avg_tickets: attr()
});
Run Code Online (Sandbox Code Playgroud)
数据来自JSON api:http://domain.com/data/ticketStats?blank = blah ...所以我为这个名为ticket-stats的模型添加了一个特殊的适配器:
import JSONAPIAdapter from 'ember-data/adapters/json-api';
export default JSONAPIAdapter.extend({
host: 'http://domain.com',
namespace: 'data',
pathForType: function(type) {
return Ember.String.camelize(type);
}
});
Run Code Online (Sandbox Code Playgroud)
我在路上获得了这个模型的数据:
import Ember from 'ember';
export default Ember.Route.extend({
model () {
var ticketData;
this.store.query('ticket-stats', { teamID: 218, attUID: 'oc7569', useProd: 1})
.then(function(stats) { ticketData = stats; });
return Ember.RSVP.hash({
currentUser: this.currentUser,
ticketStats: ticketData
}); …Run Code Online (Sandbox Code Playgroud) ember.js ×2
ember-cli ×1
ember-data ×1
import ×1
ironpython ×1
java ×1
javascript ×1
json ×1
reactjs ×1
spotfire ×1
spring-boot ×1
web-worker ×1
webpack ×1
windows-7 ×1