简体   繁体   中英

Vue js : v-bind properties in v-for

quick question.

Trying to figure out (if its even possible) how can I say template length by binding properties into one object and then using v-bind to bind it

problem is I'm using v-for, so I've got deconstructed objects

<tb-header v-for="(field, index) in tableFields"
                               :id="`header${+parseInt(index)+1}`"
                               v-bind="binds.styleProperties.header"
                               :field="field"
                               :col-num="index+1"
                               :style="field.thStyle"
                               :class="field.thClass"
                               :key="index">
                    </tb-header>

I can't figure out how to create a "bind" that's shorter (like... :field="field" is dependent on the v-for deconstruction)

any ideas?

I'm not sure if I understood the question, but if you want to create a bind that is shorter, probably you can do something like:

<tb-header v-for="({ thStyle, thClass, ...field }, index) in tableFields"
   :id="`header${+parseInt(index)+1}`"
   v-bind="binds.styleProperties.header"
   :field="field"
   :col-num="index+1"
   :style="thStyle"
   :class="thClass"
   :key="index">
</tb-header>

Let me know if that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM