M
M
MarEeeeeee2020-09-30 16:03:48
JavaScript
MarEeeeeee, 2020-09-30 16:03:48

How to correctly pass PROPS to VUE.js?

This code throws an error. That the variable whichScreen is not defined. Help me please

export default {
    props:{
        elem:{
            type:Object,
            required: true,  
                      
        },whichScreen:whichScreen
    },

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Borutkin, 2020-09-30
@MarEeeeeee

whichScreen:whichScreen and what is it in general?)

elem:{
            type:Object,
            required: true,  
                      
        },
whichScreen: {
описание
}

S
silencer-spirit, 2020-09-30
@silencer-spirit

First, for objects, a key must be defined in which the function returns an empty object (or not empty). In your case, you need to decide what type whichScreen will have, judging by the naming, this is a string / numberdefault: () => ({})

props:{
        elem:{
            type:Object,
            default: () => ({}),
            required: true,      
        },
        whichScreen: {
             type: [String, Number]
             // Остальные параметры по ситуации.
         }
    },

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question