in Education by
I have a vue.js application and into a componente there's the data method thats returns a nested object like this: obj: { color: { value: '', }, shape: { value: '', }, size: { value: '', }, } Into the template a have inputs with v-models to fill these values: I can save this values into localStorage with the JSON.stringify method: methods { save() { localStorage.setItem("Itens", JSON.stringify(this.obj)) } } and I can get this values from the localStorage with the JSON.parse: created() { this.obj = JSON.parse(localStorage.getItem("Itens")) } However, when I do this into created the input fields into template aren't filled automatically with the values of obj saved in localStorage, the fields still blank. How can I get these values saved into the localStorage e fill the fields automatically with this storaged values? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Vue does not detect changes in a nested object. You'll have to create a watcher like so: Vue JS Watching deep nested object watch: { object: { handler(newVal, oldVal) { // do something with the object }, deep: true, },

Related questions

0 votes
    This question already has answers here: When to use ":"(colon) operator in javascript vs "=" operator ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: When to use ":"(colon) operator in javascript vs "=" operator ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    recently I started to work on Vue js and I want to use a javascript plugin like Isotope also I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I have this: On every second, all images move to the same random position But I want this: On ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have set up Vue so that I have a top level AppLayout component which just includes a Navigation Menu ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I was unable to find a solution that is identical with the issue I am trying to solve. If is a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I was unable to find a solution that is identical with the issue I am trying to solve. If is a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I'm trying to use createCriteria with OR on two nested objects. This is the code I'm working with ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    i have an array of objects in [ { "country": "USA", "payment": [ { "paymentType": "Visa" ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 6, 2022 in Education by JackTerrance
0 votes
    This is my object. values : { title : 'this is title ..', translate : { en : 'some texts ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    This is my object. values : { title : 'this is title ..', translate : { en : 'some texts ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    I have the following function [@bs.obj] external route: ( ~_method: string, ~path: string, ~action ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Mention what is the command to interpolate two objects in d3.js?...
asked Nov 14, 2020 in Technology by JackTerrance
0 votes
    I believe I came across this a couple months ago, but now I'm having trouble finding the answer. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    I am using this codepen https://codepen.io/anon/pen/jJXmpZ but I am struggling to implement a new ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 8, 2022 in Education by JackTerrance
...