相关疑难解决方法(0)

es6-module默认导出导入为未定义

我不确定我在这里缺少什么。我正在使用jspm和es6-module-loader进行项目。我有一个定义如下的模块:

import hooks from './hooks';
import api from './api';
import tools from './tools';

const StencilUtils = {
    hooks: hooks,
    api: api,
    tools: tools,
};

export {hooks, api, tools};
export default StencilUtils;

/* global define */
(function(root) {
    if (typeof define === 'function' && define.amd) {
        define(function() {
            return (root.stencilUtils = StencilUtils);
        });
    } else if (typeof module === 'object' && module.exports) {
        module.exports = StencilUtils;
    } else {
        window.stencilUtils = StencilUtils;
    }
}(this));
Run Code Online (Sandbox Code Playgroud)

我将此模块导入另一个文件,并像这样使用它:

import utils from 'bigcommerce/stencil-utils';

utils.hooks.on('cart-item-add', (event, …
Run Code Online (Sandbox Code Playgroud)

javascript bigcommerce jspm es6-module-loader

6
推荐指数
1
解决办法
9140
查看次数

标签 统计

bigcommerce ×1

es6-module-loader ×1

javascript ×1

jspm ×1