0

i am already sending a variable from laravel to my vuejs like below : but when i want to use it in a component as an string it gives not defined error my vue component code is like below

 export default {
        props: ['reserve_end'],
        data(){
            return {
                date: '',


            }
        },
}
// the component part
 import VuePersianDatetimePicker from 'vue-persian-datetime-picker'
    Vue.use(VuePersianDatetimePicker, {
        name: 'custom-date-picker',
        props:
            {
                min: //i want to use the reserve_end here as an string


            }
    });

and finally the html markup

                    <custom-date-picker v-model="date"></custom-date-picker>

but in the end it wont load and gives error that reserve_end is not defined i want to know how can i pass this reserve_end to the datepicker as an string here is the devtoll picture of tracing enter image description here

12
  • 1
    Are you sure you got the passing right? Tried with Vue devtools inspection? Commented Mar 27, 2019 at 19:59
  • Yes i even print it but i cant access it from the above so i get the error Commented Mar 27, 2019 at 19:59
  • 1
    In that case, just pass the prop to the component: <custom-date-picker :min="date"></custom-date-picker>, with second binding, or just directly like :min="reserve_end". Commented Mar 27, 2019 at 20:02
  • 1
    Well, anytime, you passing something you can do like, variable.toString();. Commented Mar 27, 2019 at 20:10
  • 1
    So, i I get it, you are passing value from Laravel to one component, and then to date-picker, right? :) Commented Mar 27, 2019 at 20:17

1 Answer 1

1

// First component (getting value from Laravel): export default { props: ['reserve_end'] }

Now, in the first component, you should have an access to this.reserve_end.

// template of first component <template> <second-component :date="reserve_end"></second-component> </template>

Let's pass the value to another component, using same technique - props.

// Second component (getting value from first component export default { props: ['date'] }

Now, in the second, component we can:

{{ date }}, to get the date :)

However, don't forget to inspect each component Vue devtools.

Sign up to request clarification or add additional context in comments.

2 Comments

acctualy its one component and one plugin that i exported so i want to pass data from the export default to vue.use(datepicker) , my last question is how can i receive the reserve_end in the props of downpart
'plugin' is yet another component, ready-to-get embeded into any sistem. Just as you would pass data from your own components, same should work for the 'plugins'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.