vue.js - vuex 模块的 npm 包在调度后给出错误
问题描述
我刚刚制作了一个 npm 包作为我的 vuex 的模块。经过长时间的尝试,我终于可以安装它并将其与我的 vuex 混合使用。使用此链接 ,我控制台记录了我的商店,幸运的是,操作部分包含我的 npm 包。但是当我想发送它给我一个错误:(在我的应用程序中使用它,比如:
this.$store.dispatch('orderiomApiPackageAuth/auth')
发给我错误:
[vuex] unknown action type: orderiomApiPackageAuth/auth
在我的 module.js 中:
import axios from "axios";
const state ={
restaurantInfo: {},
imprint: null
};
const mutations = {
setRestaurantInfo(state, restaurantInfo) {
state.restaurantInfo = restaurantInfo
},
setImprint(state, imprint) {
state.imprint = imprint
}
};
const actions = { //some action here }
export default {
namespaced: true,
state,
mutations,
actions
};
在我的 index.js 包中:
import myModule from '/.module.js'
function install(Vue, options ={}) {
if (!options.store) console.log('Please provide a store!!')
options.store.registerModule('desiredName', myModule )
}
export default {
install
}
并在我的 main.js 项目中使用它:
import myPackage from 'myPackage'
import store from './store'
Vue.use(myPackage, { store })
我 console.log(this.$store) 并且我意识到 action 部分包含我的模块。但我对派遣他们有疑问。
我从控制台拍了一张快照,在这里分享:
在此处输入图像描述 有什么帮助吗?:(
解决方案
推荐阅读
- redis - Sentinel和Cluster的Redis优势
- java - 无法构造 com.google.cloud.datastore.Key 的实例
- node.js - FacebookTokenError:此授权码已被使用 passport-js
- php - 如何修复 laravel 中的 gettallheaders.php 错误?
- c - 如何避免在我的 GTK3 应用程序中使用全局指针变量
- google-apps-script - 如何拥有一个有效的谷歌表格脚本,它只在空单元格上运行,而其他单元格保持完整
- java - Java抛出错误的异常
- kdb - 用空值替换无穷大,然后使用填充 q kdb 填充它们
- angular - RXJS 服务 http 调用在另一个调用后返回 null
- c - 如果浮点常量隐式转换为 int 类型,什么时候会溢出