etranz
etranz

Reputation: 1253

How do I update value of an array inside ref in vue 3

I am building an application with vuejs

I have a ref which contains an array and I want to update a single value inside it

export default defineComponent({
  setup() {
      const allQuestions = ref([{"like" => 1},{"like" => 0}]);
      allQuestions.value[1].like = 1;
   }
}

I want to update the second like in the ref array.

Upvotes: 2

Views: 5182

Answers (1)

Steven Spungin
Steven Spungin

Reputation: 29091

Javascript uses a different syntax than php for objects.

const allQuestions = ref([{like:1},{like:0}]);
allQuestions.value[1].like = 1

Upvotes: 5

Related Questions