Utilize v-model to bind to a map containing arrays, where each array is associated with a numerical

I am currently working with a map that looks like this :

data() {
  return {
    secondarySkillHistory: {
      "1": [1, 2, 4],
      "5": [1, 7, 5]
    }
  };
},

My goal is to incorporate the array in key "1" into my v-model for a checkbox:

<input
  type="checkbox"
  :id="secondarySkill.catId"
  :name="secondarySkill.catName"
  :value="secondarySkill.catId"
  v-model="secondarySkillHistory.1" <!-- doesn't seem to work -->
/>

Is there a way to achieve this task?

Answer №1

To retrieve that specific property, you can utilize the bracket notation as shown below:

 v-model="secondarySkillHistory['1']"

Alternatively, you can also use:

 v-model="secondarySkillHistory[1]"

This method works well since the key is a numerical value.

For more information on this topic, refer to property accessors.

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

Guide on effectively sorting the second level ng-repeat data in a table

I have a collection of data objects that I want to present in a tabular format with filtering capabilities. The current filter, based on the 'name' model, successfully filters the nested object 'family'. However, it does not function as ...

The WebDriverIO browser.Click function encountered difficulty locating an element while using Chrome, but it is functioning properly on Firefox

Currently, I am utilizing WebdriverIO in combination with CucumberJS for testing purposes. The following code functions correctly in Firefox; however, I encounter errors in Chrome which display element is not clickable. I am seeking a solution using JavaSc ...

Javascript function is providing unexpected output

I have a function that should display 4 different flags, but it's not working as expected. There are no error messages, but the flags are not being printed either. I've tried everything I could think of and now I'm stuck. Can someone please ...

Can you organize an array based on groups of n elements and the number of decreasing integers within each group (n-1)? The goal is to determine the total number of resulting arrays

Consider the input array: [2, 1, 4, 4, 3] In this array, a total of n-1 patterns can be identified from left to right. The resulting output will be the number 7 since the arrays are grouped as follows: [2] [1] [4] [4] [3] - 1 group (n) [4, 3] - 1 group ...

When attempting to use focusin/focusout, I encountered the following error: Uncaught TypeError - The property 'addEventListener' cannot be read from null

When attempting to utilize the DOM events focusin/focusout, I encountered an error: Uncaught TypeError: Cannot read property 'addEventListener' of null. The issue seems to be originating from main.js at lines 18 and 40. I am using Chrome as my b ...

FancyBox: Struggling to adjust dimensions accurately

Currently using Fancybox 1.2.6 in conjunction with JQuery 1.2.6, Sample Code: <script type="text/javascript> $(document).ready(function() { $("a.iframe").fancybox({ 'width' : 300, 'hei ...

On the second attempt, Firefox is able to drag the div element smoothly by itself

I have created a slider resembling volume controls for players using jQuery. However, I am facing an issue ONLY IN FIREFOX. When I drag the slider for the second time, the browser itself drags the div as if dragging images. The problem disappears if I clic ...

Encountering an issue with Vue JS axios request and filter: the function this.XX.filter is not operational

I am encountering challenges while trying to implement a basic search feature on a JSON file obtained through an API. Each component works independently: I can successfully retrieve data from the API, perform searches on non-API data, and even search cert ...

What steps do I need to take to integrate my RASA assistant into my personal website?

Deploying my rasa chatbot on my live website is my next step. While Rasa worked smoothly on my localhost server, as a newcomer to web development, I found the official guide provided by RASA in the link below a bit challenging to comprehend: The RASA guid ...

Ways to stop values from being turned into strings in javascript?

let str; let displayedNum; for (let i in imgURLArray){ str = "<li photonum="+i+">" + "<a>"+ (1+i) + "</a>" + "</li>"; $("ul.selection-list").append(str); } While looping through, I encountered an issue wher ...

Safari 10.1.1 is encountering an issue with accessing the window.innerWidth property

I'm currently working with a script that dynamically changes the font size based on the viewport size. It seems to be functioning properly in most browsers, except for Safari (I've only tested on version 10.1.1). https://i.sstatic.net/UX3az.jpg ...

Modifying the color of the tooltip arrow in Bootstrap 4: A step-by-step guide

How can I change the arrow color of the tooltip using Bootstrap 4? Here is my current code: HTML: <div class="tooltip-main" data-toggle="tooltip" data-placement="top" data-original-title="Service fee helps Driveoo run the platform and provide dedicate ...

Issue with jQuery in Internet Explorer causing difficulties loading images

I'm experiencing an issue with my website where all the images load on top of each other when the site is first loaded, creating a chaotic mess. The desired functionality is for the images to remain invisible until specific words are clicked, which is ...

Steps for organizing a particular key in a map

I need assistance sorting my map based on the "time" value, but so far, I haven't been successful in finding a solution after searching online extensively. If anyone has any insights or recommendations, please share them with me. This is how my Map ...

Issues with the jQuery slideToggle Method

Can someone assist me in identifying the issue with this code? I am attempting to implement a basic slideToggle functionality! Here is my initial attempt: $("..").slideToggle(..,..,..) This is what my current code looks like: My code: $(document).rea ...

An error occurred when attempting to parse the string into JSON

I have a question about storing data in strings. For example: var xyz = '{ Product : [' xyz = xyz + { id:"1",name:"abc"} //this is generated via a loop xyz = xyz + ']}'; $scope.data = JSON.parse(xyz); However, I a ...

What is the best way to display a component along with a variable in the true condition of a ternary operator in React/jsx?

Can anyone help me with incorporating a ternary operator inside a div that displays a component and a variable instead of a button? My current syntax is causing an error. I need to find a way to adjust it to achieve the desired outcome. <div> {thing ...

Is there a way to dynamically load a file on scroll using JavaScript specifically on the element <ngx-monaco-diff-editor>?

I've been attempting this task for over a week now in Angular without success. Would someone be able to provide guidance? The onContainerScroll() function isn't being triggered, and I'm considering using JavaScript instead. How can I achiev ...

Issue: The input must either be a single String containing 12 bytes or a string consisting of 24 hexadecimal characters. This problem appears in the context of MongoDB and node.js

Please add the description hereI am attempting to make a get request for each individual blog when they are clicked, however I am encountering an error. Below is the code snippet in question. <% blogs.forEach(blog => { %> <a href="/blo ...

The absence of a defined HTMLCollection [] is causing an issue

rowGetter = i => { const row = this.state.estimateItemList[i]; const selectRevison = this.state.selectedEstimate.revision; const rowLenght = this.state.estimateItemList.length; const changeColor = document.getElementsByClassName('rd ...