0

view.blade.php:

<div id="dashboard">
        <calendar someattr="xxx"></calendar>
        <calendar someattr="yyy"></calendar>
</div>

app.js:

import Calendar from './components/Calendar.vue';

new Vue({

    el: '#dashboard',

    components: {
        Calendar
    }

});

Calendar.vue:

    <template>
       ... some code ...
    </template>

<script>
    export default {
        props: ['someattr'],
        methods: {
          fetchEvents() {
             //HERE
          }
        }
    }
</script>

Question is: how can I get attribute "someattr" value inside my component in method fetchEvents?

1 Answer 1

1

Just like that?

<template>
  ... some code ...
</template>

<script>
  export default {
    props: ['someattr'],
    methods: {
      fetchEvents() {
        console.log(this.someattr)
      }
    }
  }
</script>
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, for you answer. But if it would be such easy way, I would not ask such question :) this.someattr == undefined
Actually I rechecked everything and what a shame, everything is working. And I don't know who vote down this answer, not me :)
@Aleksandrs Thanks anyway :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.