Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vuetify Menu not working: Property or method “on” is not defined on the instance but referenced during render

I am copying an first example from the official documentation Vuetify about Menus, but the result is an error :

"Property or method "on" is not defined on the instance but referenced during render".

<template>
        <v-app>
            <div class="text-xs-center">
                <v-menu offset-y>
                    <template v-slot:activator="{ on }">
                        <v-btn
                                color="primary"
                                dark
                                v-on="on"
                        >
                            Dropdown
                        </v-btn>
                    </template>
                    <v-list>
                        <v-list-tile
                                v-for="(item, index) in items"
                                :key="index"
                                @click=""
                        >
                            <v-list-tile-title>{{ item.title }}</v-list-tile-title>
                        </v-list-tile>
                    </v-list>
                </v-menu>
            </div>
        </v-app>
    </template>
    
    <script>
        export default {
            data: () => ({
                items: [
                    { title: 'Click Me' },
                    { title: 'Click Me' },
                    { title: 'Click Me' },
                    { title: 'Click Me 2' }
                ]
            })
        }
    </script>
like image 319
Julia Avatar asked Mar 13 '19 08:03

Julia


People also ask

Is not defined on the instance but referenced Vue?

To fix the '[Vue warn]: Property or method is not defined on the instance but referenced during render' error with Vue. js, we should make sure the reactive property we're referencing in the template is defined in the component code.

What is V slot activator?

So what does v-slot:activator=”{ on }” mean ? The activator slot is expecting to receive props, so { on } is just extracting the on property from props, in other words props. on, where on refers to the scoped props passed to the template from the tooltip component.

How do you change the size of a picture on Vuetify?

Image Aspect Ratios in Vuetify Use the aspect-ratio prop of the v-img component to set a fixed aspect ratio. The ratio between the height and width stays the same when the image is resized.

What is VUEX in VUE JS?

Vuex is a state management pattern + library for Vue. js applications. It serves as a centralized store for all the components in an application, with rules ensuring that the state can only be mutated in a predictable fashion.


Video Answer


1 Answers

In my case work but browser showed warning, adding on prop remove warning for me using vuetify 2.2.4

props: ['on']

Edit: My problem was that I was using v-on="on" outside of template that was declaring with v-slot, remove it worked for me

like image 80
franciscorode Avatar answered Oct 05 '22 08:10

franciscorode