Вот такой кодик:
components: {Help},
props: ['nav_elements'],
name: "Navigations",
computed: {
politics_show: () => {
this.politics_show_ = !this.politics_show_;
return this.politics_show_;
},
},
data: () => ({
politics_show_: false
}),
Использую так:
<v-list-item>
<v-list-item-icon>
<v-container
v-on:click="politics_show"
style="padding: 0; margin: 0"
>
<v-icon> mdi-alert-circle </v-icon>
</v-container>
</v-list-item-icon>
<v-list-item-content/>
</v-list-item>
Получаю такое:
[Vue warn]: Error in render: "TypeError: Cannot read property 'politics_show_' of undefined"
found in
---> <Navigations> at src/components/Navigations.vue
<VApp>
<Courses> at src/views/Courses.vue
<VContent>
<App> at src/App.vue
<Root>
Видимо, прикол в том, что computed вычисляется первый раз до того, как посчитается data. Обойти не получилось. Как поступают обычно?