如何发布带有 Vuex 模块的 Vue.js NPM 包? [英] How to publish an Vue.js NPM package with a Vuex module?

查看:24
本文介绍了如何发布带有 Vuex 模块的 Vue.js NPM 包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一些 Vue 组件,我想将它们放入 NPM 包中.我面临的问题是我不知道如何发布依赖于 Vuex 模块的组件.

I am developing some Vue components that I would like to place in an NPM package. The problem that I am facing is that I have no idea how to publish components that rely on a Vuex module.

我已经将这个组件库所需的所有代码整齐地放置到一个单独的 Vuex 模块中,但是当有人导入我的包时我该如何注册我的模块?

I have neatly placed all the code needed for this library of components into a separate Vuex module but how do I register my module when somebody imports my package?

我想创建一个插件是一个好的开始,但我仍然需要检查 Vuex 实例并以某种方式注册我的模块.

A good start would be creating a plugin I guess but I would still need to check for a Vuex instance and somehow register my module.

我看过很多关于如何发布 Vue 组件的教程,但没有看过更复杂的内容.

I've seen plenty of tutorials on how to publish Vue components but not something more complex.

有什么建议吗?

推荐答案

您应该能够只要求用户将您的 vuex 模块(将其作为您的包公共 api 的一部分公开)添加到您的模块中.也许这也可以作为安装功能的一部分来完成(如果您使用插件方法).

You should be able to just ask the user to add your vuex module (expose it as part of your packages public api) to your modules. Maybe that could be done as part of the installation function as well (if you use the plugin approach).

这篇关于如何发布带有 Vuex 模块的 Vue.js NPM 包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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