- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
如果我尝试按照文档的建议将命名空间作为第一个参数传递,我会得到“undefined”作为值(“test”在模块定义中设置)
...mapState('guest', {
email: state => state.email,
}),
但如果我只是这样做而不将 namespace 作为第一个参数,它会工作得很好
...mapState({
email: state => state.guest.email,
}),
我想使用快捷方式,根据文档,第一个示例应该可以正常工作...对吧?
https://vuex.vuejs.org/guide/modules.html#binding-helpers-with-namespace
这是我的模块定义:
const initialState = function(){
let state = {
email: null,
};
return state;
};
export default {
namespaced: true,
state: initialState(),
mutations: {
fill(state, data) {
Object.assign(state, data);
},
reset(state) {
Object.assign(state, initialState());
}
},
actions: {
}
};
最佳答案
您的 computed...mapState
语法是正确的,因此问题很可能出在调用 fill 突变的方式上。你在命名提交吗?
这是一个 working example .
唯一需要更改的是 state: initialState
应该是 state: Object.assign({}, initialState)
。
第一种方法将状态设置为对 initialState
对象的引用,因此填充突变中的任何更改都会覆盖 initialState
的值,而重置突变不会有任何影响。
组件
export default {
...
computed: {
...mapState("guest", {
email: state => state.email
})
},
mounted() {
// Call the fill mutation with namespace
this.$store.commit("guest/fill", {
email: "some@email"
});
// Call reset after 2 seconds
setTimeout(() => {
this.$store.commit("guest/reset");
}, 2000);
}
商店
const initialState = {
name: "dummyName",
email: "dummy@initial" // put a value here so we can see if mapState works
};
const store = new Vuex.Store({
modules: {
guest: {
namespaced: true,
state: Object.assign({}, initialState),
mutations: {
fill(state, data) {
Object.assign(state, data);
},
reset(state) {
Object.assign(state, initialState);
}
}
}
}
});
关于vue.js - vuex 模块 appState 不适用于作为第一个参数传递的模块命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56926526/
我已经为我的 Python App Engine 应用程序启用了 appstats,我可以在/_ah/stats/url 下本地访问它,但是当我部署应用程序并在 UI 中访问我的应用程序下的 apps
观看后Guido's Google IO talk并听到提到它可以扩展(从而提供记录您自己的事件的仪器机制),我仍然不知道如何做到这一点。 这些函数都是用于处理 RPC,而不仅仅是昂贵的函数(或包装器
我遇到性能问题,但我不知道它来自哪里。 createLogoutURL 和第一个数据存储查询之间的差距是巨大的......它在以下代码段落之间: loginInfo.setLogoutUrl(user
我在 gae 上有一个 Flask 应用程序,它工作正常。我正在尝试添加 Appstats 支持,但一旦启用它,我就会陷入僵局。 当我尝试使用登录的用户 ndb 模型设置 werkzeug Local
我正在使用此处记录的 Appstats: http://code.google.com/appengine/docs/python/tools/appstats.html 它工作正常,但现在每个请求都
答案here通过 Widget 显示正在退出的应用程序。 我想知道,如果我可以退出 initPlatformState(){...} 特别针对我的情况,我在 initPlatformState(){.
当我的 Activity 关闭时,我将应用程序状态数据序列化到文件中,以便在应用程序被系统终止时让我有机会重新加载状态。 这种方法(保存和恢复状态)效果很好。但是,有时,当进程被终止时,根据要加载的数
我正在本地分析我的应用程序(使用开发服务器)以获取有关 GAE 工作原理的更多信息。我的测试正在比较常见的完整实体查询和投影查询。在我的测试中,两个查询都执行相同的查询,但投影指定了 2 个属性。测试
取these stats来自post以 App Engine 博客为例: real = 107ms cpu = 141ms api = 388ms overhead = 1ms RPC Tota
我在 react-native 上使用 AppState,所以我可以知道我的应用程序何时处于事件状态或在后台。我可以使用 AppState 获得事件状态,但我无法获得后台状态,因为当我将应用程序加倍以
如何触发 AppState 监听器来检查它是否正常工作? AppState.addEventListener('change', (nextAppState) => { console.log('t
我一直在关注克隆 flutter uber 应用程序的教程,并不断收到错误消息: ** 错误:在此 MapSample 小部件上方找不到正确的提供程序**,我正在尝试将地理位置添加到我的应用程序中,我
我正在使用GWT和Google API引擎的项目中工作。该项目没有依赖项管理器,因此我们正在实现Gradle。 问题是我们在执行过程中遇到一些错误。与Appstats基本相关。 这是错误: FAILE
在分析 Appstats 跟踪 datastore_v3.Get 调用时,了解正在从数据存储区检索哪些实体将非常有帮助。是否有隐藏的配置标志可以启用此功能? 我尝试在 appengine_config
我有一些代码想要在我的应用程序从后台恢复时运行。为此,我使用 AppState.addEventListener() 注册一个事件。 const handleAppStateChange = ()
我在获取 Appstats 时遇到问题才能正常工作。使用/appstats 或/appstats/stats 会陷入无限循环,不断重定向回/appstats/stats。这会导致 404 错误,指出页
我正在使用 Google AppEngine (python),我的应用程序日志使用 UTC。然而,我的 AppStats 正在返回看起来像 PST 的内容。 如何将 AppStats 使用的时区更改
我们的应用程序每秒处理几十个请求,其中一小部分比其他请求花费更多的时间来处理。我们有兴趣“剖析”那些缓慢的请求,但是 appstats 似乎只保留已处理请求的小窗口,因此我们感兴趣的请求很快就会消失。
我的 java appengine 应用程序中有几个 servlet,它们在内存中进行排序并按秒顺序完成。这些完全没有错误。 但是,我最近为 appengine 启用了 appstats 并开始收到以
如果我尝试按照文档的建议将命名空间作为第一个参数传递,我会得到“undefined”作为值(“test”在模块定义中设置) ...mapState('guest', { email: stat
我是一名优秀的程序员,十分优秀!