Answer the question
In order to leave comments, you need to log in
In which function to read bookmarks from chrome when using vue?
I'm making a chrome extension using vue. I need to read bookmarks. They are read asynchronously and always after the application is executed.
I couldn't catch them in lifecycle events. Anyway, if you do console.log(), then the function for getting bookmarks is executed last.
As I understand it, bookmarks must be guaranteed to be read before the vue is created, or the component must be re-rendered when they are read. Tell me how to do it?
export default {
name: 'App',
components: {
BkContener
},
data () {
return {
bookmarks
}
},
methods: {
getBookmarks(bookmarkTree) {
chrome.bookmarks.getTree((bookmarkTree) => {
console.log('bookmarks tree -> ' + bookmarkTree);
console.log(bookmarkTree);
}
}
},
Answer the question
In order to leave comments, you need to log in
I assume you are going to do this:
export default {
name: 'App',
components: {
BkContener
},
data () {
return {
bookmarks: null
}
},
methods: {
getBookmarks(bookmarkTree) {
chrome.bookmarks.getTree((bookmarkTree) => {
console.log('bookmarks tree -> ' + bookmarkTree);
console.log(bookmarkTree);
this.bookmarks = bookmarkTree; // Угадал?
})
}
}
}
<div v-if="bookmarks">
<!-- Остальной темплейт -->
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question