Home > Enterprise >  Ref an array in vuejs drop forEach undefined
Ref an array in vuejs drop forEach undefined

Time:07-29

I have this piece of code :

console.log(this.$refs[`roomRows${this.currentRoom}`]);
(this.$refs[`roomRows${this.currentRoom}`] || []).forEach((r) => {
    (window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame)(
          () => {
            // eslint-disable-next-line no-param-reassign
            r.scrollLeft = scroll.position.x;
          },
        );
      });

I have a error : (this.$refs["roomRows".concat(...)] || []).forEach is not a function, but this ref exist on the page, because I have the result in console.log;

Please see the error from browser:

enter image description here

Any ideas please ?

CodePudding user response:

The output of console.log, as can be seen, is an enter image description here

  • Related