I have a table generated using an array of objects.
(我有一个使用对象数组生成的表。)
I am having a hard time figuring out how to use computed properties to filter the array of objects.(我很难弄清楚如何使用计算属性来过滤对象数组。)
I am using VuE.js.(我正在使用VuE.js。)
I'm not sure how to properly use the filter() in my computed properties to filter the table.(我不确定如何在计算属性中正确使用filter()来过滤表。)
new Vue({
el:"#app",
data: () => ({
search:'',
programs: [],
editableKeys: ['date', 'company', 'funding', 'funded', 'recruit', 'program'],
}),
created () {
this.getPrograms();
},
methods: {
getPrograms() {
axios.get("https://my-json-server.typicode.com/isogunro/jsondb/Programs").then(response => {
this.programs = response.data.map(program => ({
...program,
isReadOnly: true,
dropDowns: ["Apple","Google"]
}));
}).catch(error => {
console.log(error);
});
},
editItem (program) {
program.isReadOnly = false
},
saveItem (program) {
program.isReadOnly = true
console.log(program)
alert("New Value: "+program.company)
alert("Previous Value: "+program.company)
},
bgColor (program) {
return program.funded === program.funding ? 'yellow' : 'white'
},
formatDate(program){
var formatL = moment.localeData().longDateFormat('L');
var format2digitYear = formatL.replace(/YYYY/g,'YY');
return moment(program.Date).format(format2digitYear);
},
updateField(program){
console.log(program)
alert(program)
}
},
computed: {
searchContents(){
this.programs.filter(this.search === )//??? not sure how to filter correctly
}
}
})
Here's the pen
(这是笔)
ask by OLA translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…