在npm上下载了一个编辑器的插件,由于有需求 把源码改动了,
通常vue中引入都是这样写的,改动完的npm包应该如何引用
我看这个模块的package.json
里的main
指向的是release/wangEditor.js
,这也就意味着你import E from 'wangEditor'
=== import E from 'wangEditor/release/wangEditor.js'
。
如果你修改了源码指的是修改了release/wangEditor.js
,那你大可以把release/wangEditor.js
拷贝到本地文件夹然后用相对路径引用。
又或者,将release/wangEditor.js
放到public/文件夹或者发布到cdn,然后在html
文件<head>
中用<script>
引入,然后在vue中使用var E = window.wangEditor
。
你可以查看一下 npm 的文档。可以使用本地路径引入包的。
As of version 2.0.0 you can provide a path to a local directory that contains a package. Local paths can be saved using npm install -S or npm install --save, using any of these forms:
../foo/bar
~/foo/bar
./foo/bar
/foo/bar
in which case they will be normalized to a relative path and added to your package.json. For example:
{
"name": "baz",
"dependencies": {
"bar": "file:../foo/bar"
}
}
13 回答12.7k 阅读
7 回答1.8k 阅读
9 回答1.6k 阅读✓ 已解决
6 回答841 阅读
3 回答1.1k 阅读✓ 已解决
3 回答1.3k 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
下载源码,修改,重新打包,覆盖mode_modules中的文件