0
var v_root = new Vue({
    delimiters: [ '[[', ']]' ],
    el: '#vue-main',
    data: {
        jobs: [],
        report_links: '{{ report_links }}',
    },
    mounted: function() {
      console.log(this.report_links);
      <-- this logs the expected data-->>
    },


Vue.component('overview', {
    delimiters: [ '[[', ']]' ],
    props: ['jobs', 'report_links'],
    mounted: function() {
      console.log(this.report_links);
      <-- this logs 'undefined' -->
      console.log(this.jobs)
      <-- this logs jobs as expected-->>
    },

Why am I able to access jobs from my component but not report_links?

Not sure if it matters but report_links should return [&#39;test1&#39;, &#39;test2&#39;]

1
  • Can you share a codepen or jsfiddle? Commented Jun 5, 2019 at 17:59

2 Answers 2

1

Looks like you figured this out in the time I was able to type this up.. For what it's worth:

[CodePen Mirror]

var v_root = new Vue({
    el: '#vue-main',
    data: {
        jobs: ["job1","job2"],
        report_links: '{{ report_links }}',
    },
    mounted: function() {
      console.log(this.report_links);
      //<-- this logs the expected data-->>
    },
})


Vue.component('overview', {
    delimiters: [ '[[', ']]' ],
    props: ['jobs', 'report_links'],
    mounted: function() {
      console.log(this.report_links);
      //<-- this logs 'undefined' -->
      console.log(this.jobs)
      //<-- this logs jobs as expected-->>
    },
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script>

<div id="vue-main">
  <overview 
    :jobs="jobs"
    :report_links="report_links">
  </overview>
  
  <ul>
    <li v-for="(job, index) in jobs" :key="index">
    {{ job }}
    </li>
  </ul>
  <div>
  {{ report_links }}
  </div>
</div>

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

Comments

1

I forgot to pass the report_links like so:

 <overview :jobs=jobs :report_links=report_links></overview>

this fixed.

Comments

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.