我正在构建一个简单的Vue项目,以掌握简单的商店(vuex),然后使用PouchDB。我遇到了一个奇怪的错误,正在努力寻找 下一步去哪里
const PouchDB = require('pouchdb')
import EntryForm from '@/components/EntryForm.vue'
import DisplayText from '@/components/DisplayText.vue'
export default {
name: 'entryform',
components: {
EntryForm,
DisplayText
},
data() {
return {
db: [],
remote: [],
stepfwd: [],
stepback: [],
newMutation: true
}
},
created() {
//window.db or this.db does it matter ?
this.db = new PouchDB('icecream')
this.remote = 'http://localhost:5984/icecream'
this.db.sync(this.remote, { live: true, retry: true })
//any mutations are put into the stepfwd array and put into the db array
this.$store.subscribe(mutation => {
if (mutation.type !== CLEAR_STATE) {
this.stepfwd.push(mutation)
this.db.push(mutation)
}
if (this.newMutation) {
this.stepback = []
}
})
}
任何帮助者都很感激。
所有分支代码都可以在此处查看 https://gitlab.adamprocter.co.uk/adamprocter/simplevuestore/tree/pouchdb