[Vuejs]-Using ref() not reacting to reassignments – composition API

1πŸ‘

βœ…

This is not the Vue way to work with DOM, you could use slots :

export default {
  name: 'carousel',
  setup(props, { slots }) {
    const wrapperRef = ref(null);
    let noOfSlides = ref(0);

    onMounted(function () {
      console.log('slots ', slots.default());
      noOfSlides.value = slots.default().length;
    });
    function log(n) {
      console.log('n ', n);
    }
    return {
      wrapperRef,
      noOfSlides,
      log,
    };
  },
};

DEMO

Leave a comment