是否可以将piia操作划分为两个名称空间,使得访问发生在属性n1和n2上,从而:
// current
store.n1a('hi')
store.n2b()
// wanted
store.n1.a('hi')
store.n2.b()
// ugly workaround:
store.namespace1().a('hi')
// store would look like
actions: {
namespace1() {
return {
a(msg) {
console.log(msg);
},
};
....
},
},
它有助于清洁f()命名。bath.paint()和kitchen.paint()代替bathPaint()等。相似:https://vuejs.org/api/options-state.html暴露
Pinia不需要命名空间
您可以通过导入访问另一个存储库。
链接
我的建议是创建两个独立的存储,并根据需要访问它们