English 中文(简体)
如何对三个不同的小部分进行重新计算,然后取用这些内容的阵列?
原标题:How to set ref on three different div elements and then access array of these elements?

I have three div elements that I want to access. I set the same ref value on all three divs, but when trying to retrieve these elements in Vue, the elements variable is empty. WHAT I am expecting here is an array of three div elements with the same ref value.

我的同仁会对这个问题有何影响? 还是我试图以错误的方式对待这些因素?

<template>
<div class="container">
    <div ref="newsletterElement">
      Element1
    </div>
    <div ref="newsletterElement">
      Element2
    </div>
    <div ref="newsletterElement">
      Element2
    </div>
 </div>
</template>

<script>
  export default {
    name:  Test ,
    mounted() {
      const elements = this.$refs.newsletterElement;
      console.log(elements);
    }
  }
</script>
问题回答
home {{ item }} export default { name: "Home", components: {}, data() { return {}; }, computed: {}, watch: {}, created() {}, mounted() { console.log(this.$refs["myDiv"]); }, methods: {} }




相关问题
Nuxt 3 useRoute import cannot find

I am using latest nuxt version and when I tried to use the useRoute method is triggers a "Cannot Find name useRoute" but it works so I would like to know what could I be missing My package ...

Vue array dependent select not display data

I have dependent selection like this. Selection image when i console log, they have data but not render data in selection data This is what i ve tried. for Product selection has default selected value ...

How to inject Bearer Token in Axios boot file

Quasar has a different setup using boot files and my current axios.ts looks liek this: import { boot } from quasar/wrappers ; import axios, { AxiosInstance } from axios ; declare module @vue/...

Vue router and Vite Base url conflict

I use Vue Router to develop my single page application and use Vite to package my project. I want to deploy all static files (such as index.js and index.css) under another CDN domain name (cdn.example....

Vue.js change class on mounted

I have a button element with a .hover property and I need the hover animation to also happen as soon as the page is mounted. How can I attribute a class to a button on the mounted function and then ...

Laravel +Vuejs CORS issue

I am facing a dilemma wit the CORS issue. I have application that is configured as follow: API: https://abc.mydomain.com (laravel) front end: https://subdomain.mydomain.com(VueJS) Both applications ...

热门标签