-1👍
this.sessions.push(this.item);
This line means that sessions is an array. So if you want to push unique objects with key Name into sessions array you can check below:
addIntoArray(yourNewlyAddedObject){
var is_in = false;
this.sessions.forEach(function (session) {
if (session.Name === yourNewlyAddedObject.Name) is_in = true;
});
return is_in;
},
Check new item with addIntoArray(obj)
function. If this function return true then this means the currently added object key “Name” is already in array. Else it returns false. So add this object to sessions array if current object with key Name if not exist in array (when function returns false).
- [Vuejs]-Toggle active class between child components VueJS
- [Vuejs]-Webpack commonchunks vue-router, only showing 1 chunk
Source:stackexchange.com