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]