Home > Blockchain >  How can you convert a string with the name of an array to render the array in vue.js template
How can you convert a string with the name of an array to render the array in vue.js template

Time:01-28

<b-card v-for='callType in callTypes' no-body >
    <b-table striped hover :items="{{callType.lineType}}">
    </b-table>
</b-card>

When each callType is the name of an array.

callTypes: [mainLine, etc]
mainLine:  [firstline: number, etc etc]

Error: vue.runtime.esm.js?2b0e:619 [Vue warn]: Invalid prop: type check failed for prop "items". Expected Array, Function, got String with value "mainLine".

CodePudding user response:

If your array is declared in data() then you could access it this way:

<b-card v-for='callType in callTypes' no-body >
    <b-table striped hover :items="$data[callType.lineType]">
    </b-table>
</b-card>
  •  Tags:  
  • Related