M
M
marselzo2021-06-08 07:53:43
Vue.js
marselzo, 2021-06-08 07:53:43

How to correctly pass props to a component?

Gives an error if default is empty, how is this solved correctly?

props: {
            orderId: { type: Number, default: ''},
            companyId: { type: Number, default: ''},
            financeId: { type: Number, default: ''},
            orderServiceId: { type: Number, default: ''},
        },

Here is the error from the console

vue.common.dev.js:630 [Vue warn]: Invalid prop: type check failed for prop "orderId". Expected Number with value 0, got String with value "".

found in

---> at resources/js/components/task/CreateTask.vue
at resources/js/views/Tasks.vue
at resources/js/views/App.vue

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kuznetsov, 2021-06-08
@dima9595

Does the translator not translate anymore? It clearly states that the Number type expects a number, such as 0 . If you really want to specify empty strings, then change the type to String .
And learn to read the documentation already.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question