如何导入navigo使用systemjs模块?这是我的代码:
import { Navigo } from 'navigo';
const router = new Navigo(null, true, '#!');
router.on({
........
}).resolve();
最佳答案
我无法使用现代 ES6 语法导入
这个包,必须使用:
let Navigo = require('navigo');
我必须使用此语法导入 Navigo 的原因是 Navigo 导出自身的方式。
Navigo was exported in the form of UMD. And the way which was chosen to export Navigo to commonjs module loader is to replace the export object with the constructor function of Navigo. Therefore, the author of @types/navigo have to export Navigo with export = Navigo, the syntax which was designed to import commonjs module in TypeScript.
关于javascript - 使用systemjs模块导入navigo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46244933/