I've defined a Vue.js component as shown below:
module.exports = Vue.component('folder-preview', {
props: ['name', 'path', 'children', 'open'],
template: `...
`,
methods: mapActions([
]),
computed: mapState([
]),
data: ()=> {
console.log(this);
return {
collapsed: (this.open !== 'true')
}
}
});
Essentially, my goal is to maintain collapsed
as a local data property within the component while using the value passed in the prop as the initial value. However, it seems like this.open
is always undefined. When I console.log this
, it displays an empty object, leaving me puzzled as to why this might be happening.
Could I be misunderstanding something here?