0๐
No need for promises or async
/await
. You could simply set a local data property in your $db.insert
callback (convert that to an arrow-function beforehand to preserve context):
// script
export default {
data() {
return {
doc: null, ๐
}
},
methods: {
savePreset() {
...
this.$db.insert(doc, (err, newDoc) => {
if (err) {
console.log(err)
} else {
console.log(newDoc)
this.doc = newDoc ๐
}
})
}
}
}
//template
<ul>
<li v-for="(val, key) in doc" v-if="val">{{key}}: {{val}}</li>
</ul>
- [Vuejs]-[Vue warn]: Error in render: "TypeError: Cannot read property 'type' of undefined"
- [Vuejs]-How can i call a method in a hiperlink?
Source:stackexchange.com