problem description
In thevue project, the data is entered on the home page, saved and displayed on the history page using localStorage, and the new data will always overwrite the old data.
the environmental background of the problems and what methods you have tried
I have referred to the answers under similar questions, but failed. I have tried to use arrays, objects, and so on.
related codes
/ / Please paste the code text below (do not replace the code with pictures)
send data:
clickdetail: function () {
var storage = window.localStorage
var contrastdata = {}
contrastdata.chepai = this.$refs.nowchepai.value
contrastdata.time = this.$refs.nowtime.innerText
contrastdata.chexin = this.$refs.nowchexin.value
storage.setItem("contrastdata", JSON.stringify(contrastdata))
}
receive data:
var contrastdata = JSON.parse (storage.getItem ("contrastdata"))
var chepai = contrastdata.chepai
var chexin = contrastdata.chexin
var time = contrastdata.time
what result do you expect? What is the error message actually seen?
expect the page to show that there is no data coverage problem, so you can record it one by one.