1 回答

TA贡献1921条经验 获得超9个赞
一个很好的用例Set:使self.working成为一个Set对象,并向其添加/删除值。
Set 就像一个数组,但它没有顺序。
export default {
data: function() {
return {
working: new Set()
}
},
methods: {
respondToClickA: function() {
let self = this;
if(!self.working.has('a'))
{
self.working.add('a')
axios.get('/ajax')
.then(function(response){
self.working.delete('a');
});
}
},
respondToClickB: function() {
let self = this;
if(!self.working.has('b'))
{
self.working.add('b');
axios.get('/ajax')
.then(function(response){
self.working.delete('b');
});
}
}
}
}
添加回答
举报