I want to point from the data attribute to a function on methods, but I can't get manage to find the correct way to do it.
this is my template (the part that is relevant):
<v-tooltip
left
v-for="(actionData, action) in actions"
:key="action"
>
<v-btn
fab
small
@click="actionData.func"
slot="activator"
>
<v-icon>{{ action }}</v-icon>
</v-btn>
<span>{{ actionData.alt }}</span>
</v-tooltip>
this is my data:
actions: {
add: {
func: () => openComponentStepper('demo'),
alt: '....',
},
build: {
func: () => this.openDialog('test'),
alt: '....'
},
adjust: {
func: () => {},
alt: '....'
},
update: {
func: () => this.openDialog('ttl'),
alt: '....'
},
},
I have a function under methods called openDialog, but every time I'm tring to execute it from this pointer I have under data it throws me this error:
TypeError: _this.openDialog is not a function
This is the full data attribute:
data: () => ({
rules: {},
fab: false,
descriptionHeaders: [],
dialog: {
target: false,
title: '',
fields: [],
save: () => {},
},
ignoerdFields: ['ignore', 'monitor', 'target'],
actions: {
add: {
func: () => openComponentStepper('demo'),
alt: '....',
},
build: {
func: () => this.openDialog('test'),
alt: '....'
},
adjust: {
func: () => {},
alt: '....'
},
update: {
func: () => this.openDialog('ttl'),
alt: '....'
},
},
}),
openDialogin your methods. Can you show your wholedatamethod? My first thought is that thethisin the code you've shared isn't pointing to the vue instance.datamethod. Arrow functions bindthisto the parent scope, which is not the Vue instance in this case.