我正在为Pouch/CouchDB开发一个Vue插件,它将是开源的,但只要我能解决我遇到的问题:
目前我正在尝试使插件与Vuex紧密相似,具有内部状态,并检测更改,并在发生时呈现视图.
在Vue实例中我正在初始化一个对象,并且在该对象中,我试图使用defineReactive使两个或三个对象反应,直到这里它是好的.
但是当我尝试更改该对象内的某些值时,更改不会传播到View.但是,如果我明确地调用它.$ bucket._state.projects .__ ob __.dep.notify(),变化传播.
Vue实例的当前对象表示如下: Vue { $bucket: { _state: { projects: {} } } }
$bucket._state已初始化defineReactive.我相信它应该有效,但我不确定在这种情况下究竟是什么问题.
任何的想法?
部分代码,这里的类几乎相似 Vuex.Store({})
constructor(schema = {}) {
// Getting defineReactive from Vue
const { defineReactive } = Vue.util;
// Ignored Schema Keys
const ignoredKeys = [
'config',
'plugins'
];
// Internal Variables
this._dbs = {};
// Define Reactive Objects
defineReactive(this, '_state', {});
defineReactive(this, '_views', {});
// Local Variables
if (!schema.config) {
throw new Error(`[Pouch …Run Code Online (Sandbox Code Playgroud) vue.js ×1