``I'm facing an issue with Vue.js where the values are not updating as

I am facing a peculiar issue that I can't seem to resolve. The testArray is expected to update its value from 'This is a test' to the array in ItemList, and it does so. However, it seems to be updating itself with a delay - when I change the emit to ('response', items), it doesn't work as expected. But, when I replace 'items' with 'test', it displays the array correctly.

Any assistance on this matter would be greatly appreciated!

App.vue

<script setup>
  import ItemList from "./components/ItemList.vue";
  import {ref} from "vue";

  const testArray = ref('This is a test')
</script>
<template>
  <ItemList @response="(msg) => testArray = msg" />
  <ul>
    <li v-for="item in testArray" :key="item.id">
      {{item.name}}
    </li>
  </ul>
</template>

ItemList.vue

<script setup>
  import {ref} from "vue";
  const items = ref([
    {id: 1, name: 'SomeRandomName'},
    {id: 2, name: 'SomeRandomName'},
    {id: 3, name: 'SomeRandomName'},
  ])
  const test = ref(['Something'])
  const emit = defineEmits(['response'])
  emit('response', items)
</script>

<template>

</template>

Answer №1

Have you experimented with the following:

send('result', data.values)

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

Issue with Express.js: "opencv" module not found within a Docker container

Currently, I am in the process of setting up the OpenCV bindings for NODE to enable AI functionality on my express server. For this purpose, I am utilizing the Peter Braden Library - https://github.com/peterbraden/node-opencv. However, I am encountering a ...

JavaScript causing Axios network error

Recently, I've started exploring the combination of axios and stripe in my project but unfortunately, I have encountered some challenges. Whenever I attempt to initiate a post request using axios, an error pops up which looks like this: https://i.sta ...

"Can you help me understand how to establish a character limit for the MUI autocomplete

Hey everyone, I have successfully created an auto-complete feature using Material UI and an API. Now, I am facing a challenge where I need to limit the suggestions returned by the autocomplete to only show matches when the user types at least 3 letters. Ca ...

interaction between modernizr and ajax causing loading issues

I am currently utilizing modernizr.js and a customized ajax function on my page to refresh the content every x seconds. Below is the snippet of code for the functions being triggered. function reloadSlides() { jQuery.ajax({ url: document.locat ...

Executing Continuous Process using Node.js

I am currently working on a server project that involves streaming webcam footage and other functionalities. Everything is set up within my node.js server, with an HTML page that includes a select drop-down menu linked to a JavaScript function via socket.i ...

Locate all buttons on the page that have an onclick function attached to them, and

I seem to have run into an issue. I am currently working with Java and WebDriver. My goal is to navigate to , locate the item "ipod", receive 4 results, and then compare them by clicking on the "compare" button beneath each item. However, I am encounteri ...

I have successfully converted an SQL Join query into JSON, but now I am unsure of how to interact with the

I recently ran an SQL Join on two tables and obtained the following results: _____People_____ name: "Jane" age: 35 job_id: 1 _____Professions_____ job_id: 1 title: "Teacher" "SELECT * FROM People INNER JOIN Professions ON People.job_id = Professions.job ...

Can we establish communication between the backend and frontend in React JS by utilizing localstorage?

Trying to implement affiliate functionality on my eCommerce platform. The idea is that users who generate links will receive a commission if someone makes a purchase through those links. However, the challenge I'm facing is that I can't store the ...

JavaScript Nested Array Looping Script

I am currently working on a loop script for my application that checks for the full capacity of a user array and adds a user ID if there is space available. The data in my JSON file is structured around MongoDB and contains 24 entries (hours). Each entry ...

Angular 2 module that is loaded lazily - service does not follow singleton pattern

After successfully implementing lazy loading modules into my application, I have ensured that the app.module.ts is properly configured. @NgModule({ declarations: [ AppComponent, HeaderComponent, HomeComponent ], imports: [ BrowserMod ...

Access the global window variable from index.html within a Vue component

In my Vue project, I am incorporating an Stencil.js component in the following manner: index.html: <script type="module" src="https://xxxxxx.s3-eu-west-1.amazonaws.com/topbar.esm.js"> </script> <script> window.addEventLis ...

Remove the style using tags and JavaScript

How do I remove the style attribute from an img tag? <div id='someID'> <p> <img style="width: 585px;" src="somesrc"> </p> </div> Delete the style attribute only using JavaScript and by tag. <div ...

Managing the appearance of one DOM element using another DOM element

Hey there, I'm currently working on an Angular Material tooltip implementation. When I hover over my span element, the tooltip appears. Now, I'm wondering how I can dynamically change the background color of the tooltip based on certain condition ...

Modify the elements in the array based on the user's input

My goal is to create a component within my application where the number of paragraphs rendered adjusts based on user input. For example, if the user selects 3, then 3 paragraphs should be displayed. However, if the user subsequently selects 1, the number o ...

Guide on transferring a wav audio file with javascript and webapi in C#

In order to send an audio wav file to the WebAPI controller for Microsoft Bing Speech API calls, the following steps have been taken: The audio was recorded and converted to base64 data using JavaScript on the client side. An AJAX call was made to in ...

I'm looking to learn how to implement the delete method in an API using TypeScript. Can anyone help me out

I am seeking guidance on utilizing 'axios' within 'nuxt.js'. I have experimented with sample data, and I am particularly interested in learning how to utilize the 'axios' method within 'nuxt.js' using TypeScript. T ...

The Vue method is triggered multiple times during the rendering process

My goal is to design a Vuetify carousel featuring three elements in a custom component named AlbumCarousel. Each element represents an album as an albumPreview, and all albums are listed in the categorieAlbums within the data. I'm utilizing a v-for lo ...

Decide whether an angular rotation is within the camera's field of vision inside a spherical object

Seeking assistance with a three.js project. I have set up a camera inside a SphereGeometry at position (0,0,0) and am projecting an image on the sphere's wall. My goal is to create interactive JS elements outside of the threejs framework that respond ...

Denied running the inline script in Redocly

Experimenting with redoc-cli (https://github.com/Redocly/redoc/) in order to generate static documentation. Unfortunately, encountered some stumbling blocks due to errors related to the Content-Security-Policy, which seems to be blocking JavaScript code ex ...

Tips on automatically adjusting the width of a div to fit the content, maintaining center alignment, and ensuring the contents float to the left

I am facing an issue with a div element that has multiple children. My goal is to have the children neatly fit to the bottom left of the grid when the window expands, utilizing the next available space efficiently. However, as the div expands with the wind ...