[英]vue js import from node_modules
I am new to vue js and currently trying to import any vue plugin/component into other sfc.vue files for usage.我是 vue js 的新手,目前正在尝试将任何 vue 插件/组件导入其他 sfc.vue 文件以供使用。
Currently I am using VS code with vue create project
cli setup and in my main App.vue
file I am trying to import plugin after installation via npm.目前我正在使用带有
vue create project
cli 设置的 VS 代码,在我的主App.vue
文件中,我试图在通过 npm 安装后导入插件。
I have came across this code at many places but not sure from where this has been imported.我在很多地方都遇到过这段代码,但不确定是从哪里导入的。 Also not sure how this path system works?
也不确定这个路径系统是如何工作的?
import SomePlugin from 'some-plugin';
My guess is that this comes inside node_modules folder after npm install cli part.我的猜测是,这在 npm 安装 cli 部分之后出现在 node_modules 文件夹中。 Do we need to include full path of node_modules folder or vue-cli handles this automatically as full path looks weird.
我们是否需要包含 node_modules 文件夹的完整路径,或者 vue-cli 会自动处理这个,因为完整路径看起来很奇怪。
import SomePlugin from '../node_modules/some-plugin';
Importing using only the package name will always look in the node_modules
folder, regardless of whether the node_modules
is in the current directory, the parent directory, or the global directory.仅使用 package 名称导入将始终在
node_modules
文件夹中查找,无论node_modules
是在当前目录、父目录还是全局目录中。 Unless if the path is preceded by ./
, ../
, etc.除非路径前面有
./
、 ../
等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.