How can I access the value of `this.names` from within a foreach loop?
This is what my code looks like:
<template><div><li>{{ names }}</li></div></template>
var initData = {
names: '',
}
}
export default {
data: function () {
return initData
},
props: ['nameData'],
methods: {
printNames: function () {
let tempData = JSON.parse(JSON.stringify(this.nameData))
tempData.biglist.forEach(function (nObj) {
let cName = nObj.CeName
console.log(cName) // gives long list of names
this.names = cName
})
}
},
I would like to populate my list with the `names` value. Thank you in advance for your help :)