在“./n"中找不到导出“默认"(导入为“n") [英] export 'default' (imported as 'n') was not found in './n'

查看:25
本文介绍了在“./n"中找不到导出“默认"(导入为“n")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想包含模块的命名空间,当我这样做时,它给了我警告,(我的代码不起作用),我正在像这样导入我的模块

I want to include namespace of modules, and when I do it, it gives me warning, (and my code won't work), I'm importing my module like that

import * as agl from "./agl";

并像这样使用它:

var vbo = new agl.VertexBuffer();

我的模块只是将模块包含到单个命名空间中:

My module just consists of including modules into single namespace:

import VertexArray from "./VertexArray";
import Display from "./Display";
import VertexBuffer from "./VertexBuffer";
import IndexBuffer from "./IndexBuffer"
import Shader from "./Shader";
import ShaderProgram from "./ShaderProgram";
import Texture from "./Texture";
import BufferLayout from "./BufferLayout";




export default {
  VertexArray,
  Display,
  VertexBuffer,
  IndexBuffer,
  Shader,
  ShaderProgram,
  Texture,
  BufferLayout
}

可能是什么问题,如何导入模块的命名空间?

What could be the problem, and how can I import namespace of modules?

推荐答案

export default {
  VertexArray,
  Display,
  VertexBuffer,
  IndexBuffer,
  Shader,
  ShaderProgram,
  Texture,
  BufferLayout
}

这太可怕了,会导致您的问题.该模块默认导出对象文字,而不是仅使用命名导出.你应该使用

This is horrible, and causing your problem. That module does default-export an object literal, instead of just using named exports. You should be using

export {
  VertexArray,
  Display,
  VertexBuffer,
  IndexBuffer,
  Shader,
  ShaderProgram,
  Texture,
  BufferLayout
}

而是让您的 import * as agl ... 工作.

这篇关于在“./n"中找不到导出“默认"(导入为“n")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆