The Vue function triggers multiple times in succession

I have been working with vue cli and encountered an issue with a function that updates text @click, but it keeps running multiple times:

User.vue

<div  @click="newText('Volume')">
<Chart :text=text ></Chart>
volume
</div>

<div  @click="newText('Temperature')">
<Chart :text=text ></Chart>
temp
</div>

<div  @click="newText('Weight')">
<Chart :text=text ></Chart>
weight
</div>

<script>
newText: function(argT) {
        const text = argT;
        this.text = text;
        console.log('text', this.text);
</script>
},

When I checked the Chart component by console.log, it ran 9 times!

props: ['text'],

text1(){
       console.log('text', this.text)
    },

https://i.sstatic.net/t00T3.jpg

I realized that since my User component is displayed thrice intentionally (due to an array of 3 users I have), with a box for each measurement (temp, vol, and weight), it's running 9 times. However, I'm uncertain why it runs each time.

I would appreciate if it executed only once for the specific box I clicked on. Any assistance would be greatly appreciated, thanks!

Update (Additional Code)

User.vue

<template >
   
<div class="user"> 
<div v-for="(item, index) in users" :key="item.id">
 <div>
    <div @click.stop="myFunction(index); newData(index, item.Vol); newText('Volume')">
 <v-touch v-on:doubletap="isOpen = !isOpen;"   >
   <transition name="modal">
      <div v-if="isOpen">
        <div class="overlay" @click.self="isOpen = false;">
          <div class="modal">
               <Chart :text=text :dat=dat ></Chart>
           </div>
         </div>
       </div>
 </v-touch>
               volume </div>

     <div @click.stop="myFunction(index);newData(index, item.Temp); newText('Temperature')">
 <v-touch v-on:doubletap="isOpen = !isOpen;"   > 
  <transition n...

and finally I pass text to a chart:

<template>
    <div id="container" ref="chart"></div>
</template>

<script>
 title: {
         text: this.text,   
        }
 series: [ {
        name: this.text,   
        data: this.dat,
       
    }],

Answer №1

I found that browser-sync was causing the issue for me.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Karma Test Requirement: make sure to incorporate either "BrowserAnimationsModule" or "NoopAnimationsModule" when using the synthetic property @transitionMessages within your application

TEST FILE import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { BrowserAnimationsModule } from '@angular/platform- browser/animations'; import { ManagePageComponent } from './manage-page.component& ...

Troubleshooting issue with error handling in graphql mutation hook with react and apollo is not resolving

It seems like I might have overlooked a configuration in my code, but I can't seem to pinpoint where I went wrong. In our application, we have a basic login form. If the correct username and password are entered, everything works smoothly. However, ...

Tips for sharing content within an iframe

Despite my efforts to find a solution, I have been unable to come across one that aligns with my specific situation. I currently have a form for inputting person data. Within this form, there is an iframe containing another form for adding relatives' ...

Is there a way to determine the number of clicks on something?

I'm attempting to track the number of times a click event occurs. What is the best method to achieve this? There are two elements present on the page and I need to monitor clicks on both of them. The pseudo-code I have in mind looks something like ...

Submitting a Form with Multiple Pages

I'm encountering a challenge that I'm struggling to work through. Initially, we had a professional build our website, but since parting ways with the company, I've taken over site management. While I can handle basic tasks, I lack the expert ...

Issue with Generating divs dynamically in Ionic Framework

I'm currently working on dynamically generating a board game using divs in AngularJS, like so: HTML: <div class="boardgame" ng-repeat="square in board"> <div class="square"></div> </div> JS: $scope.board = [ {value: ...

Executing functions from a separate Python file: A step-by-step guide

As I am still learning Python, here is the situation I am facing. Let's say I have a Python file named functions.py which contains a class with my functions. Below is an example. import json class Functionalities: def addelement(element): ...

What is the most effective method for embedding a Kotlin program into a website?

I have created a combat simulation tool in Kotlin for an online gaming community. Users can input the combat levels of two players, choose the number of duels to simulate, and then initiate the simulation which will provide win percentages and other stats. ...

Having trouble retrieving a specific value from a json object

Below is the JSON data that I am dealing with: var data = {200x200: "url1", 400x400: "url2", 800x800: "url3"}; After stringifying the object and attempting to access "200x200," I encountered an issue: undefined data = JSON.stringify(data); //data = ...

In Angular, iterate through each country and assign a value of 0 to any blank fields

My challenge is to dynamically generate empty objects with a value of 0 for each country in relation to all months. Check out my plunker example: http://plnkr.co/edit/6ZsMpdFXMvGHZR5Qbs0m?p=preview Currently, I only have data available for 2 months per co ...

Error Timeout Encountered by Langchain UnstructuredDirectoryLoader

I am facing an issue while trying to load a complex PDF file with tables and figures, spanning approximately 600 pages. When utilizing the fast option in Langchain-JS with NextJS Unstructured API, it partially works but misses out on some crucial data. On ...

Expo + tRPC: Oops! Looks like the application context couldn't be retrieved. Don't forget to wrap your App inside the `withTRPC` HoC for

I'm currently working on a straightforward tRPC server setup: // server.ts import { initTRPC } from "@trpc/server"; import { z } from "zod"; const t = initTRPC.create(); export const appRouter = t.router({ greeting: t.procedu ...

The Google map is failing to load on the webpage

My id="ieatmaps" is set up to call the googlemaps.js, but for some reason, it's not displaying correctly. I must be missing something. function initMap() { var map = new google.maps.Map(document.getElementById('ieatmaps'), { c ...

Guide to modifying CSS properties of an individual element by manipulating class names with JavaScript

I have been searching for an answer to my question without success. I have a unique challenge where I need to change the styles of an h1 element by adding a class based on which radio button is clicked. The issue I'm facing is that when I select a dif ...

What steps should I take to maximize the efficiency of my angular function?

Hey there, I could really use some assistance with optimizing this code snippet. Does anyone have any ideas on how to improve it? Here's the code: optimizeCode(value, fieldName: string) { if (fieldName === 'fullName') { this.billingFields. ...

Using Angular2 in conjunction with the simpleheat plugin

I've been attempting to integrate the NPM plugin Simpleheat () into my Angular2 app, but unfortunately, the heatmap is not rendering even though everything appears to be set up correctly. You can find the full repository with the issue here: https:// ...

Sequelize Error: Object A is not linked to Object B in Node.js

Two models exist: Question and Answer. Each answer has a question_id, and a question can have multiple answers. I am trying to include all the answers for each question in my JSON response but keep encountering an error: "message": "answe ...

I was caught off guard by the unusual way an event was used when I passed another parameter alongside it

One interesting thing I have is an event onClick that is defined in one place: <Button onClick={onClickAddTopics(e,dataid)} variant="fab" mini color="primary" aria-label="Add" className={classes.button}> <AddIcon /> & ...

What is the best way to route a localpath to a different page including parameters in Nuxt Js?

Hello, I am facing an issue where I need to pass parameters in the URL to another page in NuxtJs props: { idPending: { type: Number, required: true } }, methods: { fetchpage() { const orderId = this.idPending; this.$rou ...

Improve loading speed of thumbnail and full images in HTML

I'm struggling with slow loading images on my blog website. Can anyone help me figure out how to improve loading speed and: Is it possible to use a separate thumbnail image that is smaller in size instead of the full image for both thumbnails and th ...