0
store.changes
以函數作爲參數。 test
需要一個對象及其屬性作爲參數:函數不被識別爲函數嗎?
store.changes(test(this, 'posts'))
function test (obj, prop) {
store.find().then(posts => {
obj[prop] = _.map(posts.rows, (post) => post.doc)
})
}
store.changes = (func) => {
return db.changes({
since: 'now',
live: true
}).on('change', func)
}
但由於某些原因store.changes
ins't承認test(this, 'posts')
作爲一個函數,它引發以下錯誤:
Uncaught TypeError: listener must be a function
這是爲什麼?
'test(this,'posts')'不是 - 不會返回 - 函數?! – Bergi
'test(this,'posts')'change to'function(){test(thisObj,'posts'); }' –
您正在傳遞函數的結果,而不是函數。 – Seonixx