Skip to content

this.$refs.key return undefined after hot reload #6182

@Shiva127

Description

@Shiva127

Version

2.4.2

Reproduction link

No reproduction link, need hot reload...

Steps to reproduce

Use this vue file:

<template>
  <div>
    <div ref="test"></div>
  </div>
</template>

<script>
export default {
  name: 'test',
  mounted () {
    setInterval(() => {
      console.log(this.$refs.test)
    }, 2000)
  }
}
</script>

<style>
</style>

Run it then edit the file, change this.$refs.test to this.$refs.test.clientWidth, save and watch the console.

What is expected?

After hot reload, display the width of the div.

What is actually happening?

After hot reload, return undefined, then the width of the div.


It the same if you use a $refs in a function of an event listener. Even if you destroy it in deforeDestroy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions