1
以下代码基于其id返回Document
对象,然后根据对象找到其相应的部分。 document
是一个Parse对象,并且将此对象变成一个Javascript对象。 sections
是Javascript对象的数组。尝试获取对象返回未捕获的TypeError:对象函数ParsePromise()
main.js:
data() {
return {
id: '',
document: {},
sections: [],
content: ''
}
},
route: {
data ({ to }) {
return store.first(to.params.id).then((document) => ({
document: document.toJSON(),
sections: store.findSection(document).then((result) => this.sections = result)
}))
}
},
store.js:
const store = {}
store.findSection = (obj) => {
const Section = Parse.Object.extend('Section')
const query = new Parse.Query(Section)
query.equalTo('document', obj)
return query.find().then((results) =>
_.map(results, (result) =>
result.toJSON()
)
)
}
export default store
出于某种原因,store.findSelection
引发此错误:
Uncaught TypeError: Object function ParsePromise() {
_classCallCheck(this, ParsePromise);
this._resolved = false;
this._rejected = false;
this._resolvedCallbacks = [];
this._rejectedCallbacks = [];
} has no method 'all'
可能是什么亲瑕疵,以及如何解决它?
编辑:
奇怪的是,如果我做这样的事情(route
下):
main.js:
methods: {
submit() {
store.findSection(store.transform(this.document)).then((result) => this.sections = result)
}
}
store.js:
store.transform = (obj) => {
obj.className = 'Document'
return Parse.Object.fromJSON(obj)
}
个
store.findSection
工程和输出正确的事情:[Object, Object, Object]