打字稿代码:
import * as $ from "jquery";
import {Canvas} from "./canvas";
$(() => {
let canvas = new Canvas(600, 600);
canvas.init();
});
我使用browserify并将打字稿导入
var _jquery = require("jquery");
var $ = _interopRequireWildcard(_jquery);
$(function () {
var canvas = new _canvas.Canvas(600, 600);
canvas.init();
});
并抛出此错误:
Uncaught TypeError: $ is not a function
当我在控制台中用_jQuery替换$时一切正常,如何删除_interopRequireWildcard()调用?
答案 0 :(得分:1)
尝试导入jQuery的默认导出,如下所示:
import $ from "jquery";
这可以解决您的问题。