【问题标题】:How to add an npm package inside stencil js project?如何在 stencil js 项目中添加 npm 包?
【发布时间】:2020-11-15 02:36:57
【问题描述】:

我正在创建一个在其中使用 npm 包的模板项目,是否有任何选项可以在模板项目中添加一个 npm 包。我寻找解决方案的任何建议。

这就是我在 Angular 中使用 ck-editor 的方式

<ck-editor name="editor" #myEditor [(ngModel)]="templateSetValue.template_content"
            (change)="handleEditorData($event)">
        </ck-editor>

是否可以使用相同的模具项目 https://www.npmjs.com/package/ngx-ckeditor

【问题讨论】:

    标签: stenciljs npm-package


    【解决方案1】:

    不确定我是否正确理解了这个问题,但是要在您的 Stencil.js 项目中添加来自 npm 的包,您可以像在任何其他节点项目中一样安装它:

    npm install <some-package>
    

    例如nprogress:

    npm install nprogress @types/nprogress
    

    然后将其导入您的代码中,例如

    import nprogress from 'nprogress';
    
    nprogress.start();
    
    // ...
    

    【讨论】:

    • 我必须在我的模板项目中使用 ckeditor npmjs.com/package/ngx-ckeditor 这是我在 Angular 中使用的方式,我如何在模板中使用它
    • 看起来这个包是专门为在 Angular 项目中使用而编写的,那么你希望它在没有 Angular 的情况下如何工作?它可能只是一个包装器包,可以轻松地将 CKEditor 集成到 Angular 项目中。如果没有 Angular,您将不得不直接使用 CKEditor 包,例如。 G。 @ckeditor/ckeditor5-build-classic(见ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/…)。
    • 上面的 nprogress 包可以在模板项目中使用吗?如果是这样,你能给我一个工作的例子。我对 stenciljs 完全陌生,请帮助
    • 是的 nprogress 与模板一起使用。 codesandbox.io/s/loving-gagarin-rw7j5?file=/src/index.html。请注意,nprogress 默认情况下没有样式,这就是为什么除非您编写一些样式,否则什么都不可见。请参阅src/global.css 中的#nprogress 样式。
    • 你能建议我一个在顶部搜索的多选下拉包(ngx-select 下拉菜单是我通常在 angulat 中使用的),它在模板项目中工作,最后模板组件应该集成到角度
    猜你喜欢
    • 2017-09-10
    • 2021-05-05
    • 1970-01-01
    • 1970-01-01
    • 2019-08-28
    • 1970-01-01
    • 2020-12-21
    • 1970-01-01
    • 2015-12-29
    相关资源
    最近更新 更多