How to watch dom

how to watch dom

<template lang="html">
<div class="a">
  <div class="goods-container">
      <div class="goods-left" ref="leftScroll">
        <ul>
          <li class="goods-left-list" :class="{"active":currentIndex===idex}" v-for="(item,idex) in goods" :key="item.name" @click="tofood(idex)">
            <span class="text border-1px">
              <span class="icon" v-if="item.type>0" :class="icon[item.type]"></span>{{item.name}}
            </span>
          </li>
        </ul>
      </div>
data() {
    return {
      goods: [],
      icon: ["decrease", "discount", "guarantee", "invoice", "special"],
      listHeight: [],
      scorllY: 0,
      foodInfo: {},
      dom: this.$refs.leftScroll
    };
  },
``

watch: {

dom(newvalue,oldvalue) {
  console.log("aaa");
  console.log(newvalue+"-------"+oldvalue);
}

},


dom for watch    
data  dom  undefinde
Jul.05,2022

do you have a look at compiling mode or introducing vue.js mode?


data ()


DOMNodeInserted

VUE core is not data-driven. This is not suitable for VUE


initializing the dom variable in data does not cause your dom node to have a reference to the variable.
but you can write like this, for example?:

  watch example . You will know the usage of  watch . 

Menu