Cannot use this on ContextMenu command Typescript

UI Components for Vue
Post Reply
undercoverlab
Posts: 1
Joined: 12 Apr 2022, 09:50

29 Dec 2022, 13:32

I cannot call a method when defining the command option in a ContextMenu Items.

Code: Select all

<script lang="ts">
export default defineComponent({
    data: () => ({
        dtContextmenuModel: [
            {
                label: 'Ver',
                icon: 'pi pi-fw pi-search',
                command: () => this.viewProduct(),
            },
            { label: 'Editar', icon: 'pi pi-fw pi-pencil' },
        ],
    })
    methods: {
        viewProduct() {
            this.$toast.add({ severity: 'info', summary: 'Product Selected', detail: 'hellooo' });
        },
    }
})
</script>
Image

Post Reply

Return to “PrimeVue”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests