Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
TypeError: Cannot read properties of undefined (reading 'add') in vuejs

Error is happening because of this line "word.classList.add('tag')". When i was first adding a class here "if (word.includes('@')) {}" i was getting the same error, so i thought i have to push words into new array and loop them again, but the problem is something else.

export default {
  data() {
    return {
      tweets: [],
      currentPage: 1,
      numberOfPages: 0,
      showPagination: 5,
      newPage: 0,
      text: [],
      arrayOfWords: [],
    }
  },
  methods: {
      getTweets(newCurrent) {
      this.tweets = []
      const API_URL = `${this.$server}/api/twitter/tweets`

      const params = {
        token: getUserToken(),
        page: this.$route.query.page,
        newCurrentPage: newCurrent,
      }
      axios.post(API_URL, null, { params }).then(res => {
        this.currentPage = res.data.page
        this.numberOfPages = res.data.numberOfPages

        res.data.tweets.forEach(tweet => {
          const tweetData = {
            id: tweet.id,
            tweet_text: tweet.tweet_text,
            twitter_name: tweet.twitter_name,
            twitter_username: tweet.twitter_username,
            added_at: moment(String(tweet.added_at)).format('MM/DD/YYYY hh:mm'),
          }
          this.tweets.push(tweetData)
          this.text.push(tweet.tweet_text)
        })

        this.tweets.forEach(tweet => {
          tweet.tweet_text.split(' ').forEach(word => {
            if (word.includes('@')) {
              this.arrayOfWords.push(word)
            }
          })
        })

        this.arrayOfWords.forEach(word => {
          word.classList.add('tag')
          console.log(word)
        })
      })
    },
  }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

word is a string I think it has no classList, you can add classList to it if you like

word.classList = word.classList || []
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda