简体   繁体   English

为什么此导入行没有导出

[英]Why this import line doesn't have an export

I just learned import/export for JS today but I saw this code from here but it uses something like,我今天刚刚学习了 JS 的导入/导出,但我从这里看到了这段代码,但它使用了类似的东西,

import { modal, configure } from 'web3-login';

But I thought it was supposed to be like,但我认为它应该是这样的,

import { modal, configure } from './web3-login.js';

What does web3-login mean? web3-login是什么意思? It is a shorthand?是速记吗?

And also, I can't an export anywhere in the code.而且,我不能在代码中的任何地方export I thought we should have like,我想我们应该喜欢,

export function modal()

How come?怎么来的?

UPDATE: I originally found the file when I downloaded from - wordpress.org/plugins/ethpress but it doesn't use node.更新:我最初从 wordpress.org/plugins/ethpress 下载时找到了该文件,但它不使用节点。 It's just a WordPress plugin.它只是一个 WordPress 插件。 And there're no traces of web3-login text in a function or export.并且在函数或导出中没有web3-login文本的痕迹。

-- when you are importing from node_modueles you use just package folder name like 'web3-login' -- 当你从 node_modulees 导入时,你只使用包文件夹名称,如“web3-login”

-- when you import some exported function from your project structure you use './web3-login.js'. -- 当你从你的项目结构中导入一些导出的函数时,你使用'./web3-login.js'。 this means you are importing some function that is exported from same directory that you are currently into.这意味着您正在导入一些从您当前所在目录导出的函数。

It uses web3-login instead of ./web3-login.js because it's downloaded with npm (Node Package Manager).它使用web3-login而不是./web3-login.js ,因为它是使用 npm(节点包管理器)下载的。 If you were trying to import a local file you have created yourself in your folder structure you would use: ./web3-login.js but because it's now referring to a npm package you won't have to write more than just the package name.如果您尝试导入您自己在文件夹结构中创建的本地文件,您将使用: ./web3-login.js但因为它现在指的是 npm 包,您不必只写包名称.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM