0

im new to vue js

usually passing the variable to blade with @foreach

i have a joined table like this

enter image description here

so, there could be multiple ref_contract_id

i've tried with v-for, but only 4 blank rows appeared

enter image description here

here's my vue

<tr v-for="material in getmaterial">
<td></td>
<td>{{ material.product_name }}</td>
<td>{{ material.qty }}</td>
<td>{{ material.price }}</td>
<td>{{ material.budget }}</td>
export default {
  props: ['getmaterial'],
  data() {
    return {
      module_url: `${this.$root.base_url}/supplier-comparison`,
      forms: {
        action: {          
          quotation_no: '',
          project_code: '',
          rof_code: '',
          submit: 'Create',
        }
      },
    }
  },
6
  • 1
    The v-for directive is the proper way to iterate. What have you done to verify the value of the getmaterial prop? Commented Jul 7, 2020 at 15:20
  • @hmm i put getmaterial in prop because thats when im trying to check if the variable is passed without loop Commented Jul 7, 2020 at 15:26
  • Do you have 4 records on this table? Commented Jul 7, 2020 at 15:28
  • @livresonltc no, only 1 record based by the where clause Commented Jul 7, 2020 at 15:30
  • How many records you have on this table? Also share you database query and how you are fetching data from vue js. Commented Jul 7, 2020 at 15:32

1 Answer 1

2
  1. Make sure 'getmaterial' has any data by consol.log(this.getmaterial) it on mount (or in a method) in the script section or adding it in the template as {{getmaterial}}.

  2. With v-for, always use a key <tr v-for="(material, index) in getmaterial" :key="index">

V-for needs a unique key Id while iterating and index will provide the current index as an id

Hope this helps!

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

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.