vue的computed 和watch 使用

直接引入

import {
    
     ref, watch, computed } from 'vue';
  • computed
const light = computed(() => lightOri.value + 2);

  • watch
watch(lightOri, (newVal, oldVal) => {
    
      
        console.log('watch');
    },
    {
    
    
        immediate: true
    }
    )

猜你喜欢

转载自blog.csdn.net/monk96/article/details/126168614