Subscribe on changes!

Template Refs in v-for not working ( again )

avatar
Jun 1st 2022

Vue version

@vue/cli 5.0.1

Link to minimal reproduction

https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHNjcmlwdCBzZXR1cD5cbmltcG9ydCB7IHJlZiB9IGZyb20gJ3Z1ZSdcbnZhciBscyA9IFsxLDIsM11cbnZhciBpdGVtUmVmcyA9IHJlZiggW10gKVxuLy8gZml4XG4vL3ZhciBza2lwVW53cmFwID0geyBpdGVtUmVmcyB9XG4vLyArICA8ZGl2IHYtZm9yPVwiIGkgaW4gIGxzICBcIiA6cmVmPVwiIGl0ZW1SZWZzLml0ZW1SZWZzIFwiPlxuPC9zY3JpcHQ+XG5cbjx0ZW1wbGF0ZT5cbiAgPGgxPnt7IGl0ZW1SZWZzIH19PC9oMT5cbiAgPGgxPiBUb3RhbCBSZWZzOiB7eyBpdGVtUmVmcy5sZW5ndGggfX08L2gxPlxuICA8aHI+XG4gIDxkaXYgdi1mb3I9XCIgaSBpbiAgbHMgIFwiIHJlZj1cIiBpdGVtUmVmcyBcIj5cbiAgICA8cD5cbiAgICAgIHt7aX19XG4gICAgPC9wPlxuICAgPC9kaXY+XG48L3RlbXBsYXRlPlxuPHN0eWxlPlxuaHRtbCB7YmFja2dyb3VuZC1jb2xvcjogZ3JheX1cbjwvc3R5bGU+IiwiaW1wb3J0LW1hcC5qc29uIjoie1xuICBcImltcG9ydHNcIjoge1xuICAgIFwidnVlXCI6IFwiaHR0cHM6Ly9zZmMudnVlanMub3JnL3Z1ZS5ydW50aW1lLmVzbS1icm93c2VyLmpzXCJcbiAgfVxufSJ9

Steps to reproduce

<template lang="pug">

  my_comp(
   v-for=" i in ls "  
      ref=" itemRefs "
  )
  button(@click=" get_refs ")

<script setup>

import { ref } from 'vue'

var itemRefs = ref( [] )

function get_refs ()
{
  console.log(itemRefs.value)
}

What is expected?

list of components refs

What is actually happening?

[]

System Info

System:
OS: Linux 5.18 Arch Linux
CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
Memory: 50.21 GB / 62.78 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 18.2.0 - /usr/bin/node
Yarn: 1.22.19 - /usr/bin/yarn
npm: 8.5.5 - /usr/bin/npm
Browsers:
Chromium: 102.0.5005.61

Any additional comments?

wrapping is nice workaround, but components are still undefined inside, have to use div instead

  div(
    v-for=" i in  ls  " :ref=" skipUnwrap.itemRefs "
  )
    plot(
      :x_axis=' ts '
      :y_axis= ' i '
)
avatar
Jun 1st 2022

remove spaces from ref attribute

avatar
Jun 1st 2022

remove spaces from ref attribute

not that easy on pug, though

all that online editors is a rubbish..

some of them doesn't support preprocessors, some <script setup>

but i'll try, wait a min

avatar
Jun 1st 2022

and after i save and reload it - it just works ~_~

my guess this is because of formatter and visual noise ;

avatar
Jun 1st 2022

🤷

2022-06-01x21:59:40

avatar
Jun 1st 2022

delete f* yarn.lock update and remember ALWAYS BE THE BLEEDING EDGE !!!