简体   繁体   中英

vuejs, i want to print parent's id/name one time only, for its child

<td v-if="currentId != loop.id" class="text-center">
    <div :set="currentId = loop.id">{{ loop.id }}</div>
</td>
<td v-else></td>

need to achieve this its a multidimensional Parent/Child array, need to print on a table. so when first parent is printed on a row, until its child is finished, we will stop printing repetitive parent. console warning I have set currentId as loop.id, it is showing console warning.

data() {
  return {
    currentId: '0',
  }
},
methods: {
  assignCurrentId: function(id) {
    if( this.currentId == id) {
        return false;
    } else{
        Object.defineProperty(this, 'currentId', {value: id, writeable: false});
        return true;
    }
}

found something here, to stop/disable reactivity on variables, it is working now - https://stackoverflow.com/a/52844620/5156910

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