Reference a javascript property with a dynamic name

后端 未结 3 1941
北海茫月
北海茫月 2021-01-27 12:09

I\'m using Vue.js and I am wondering how I can call a javascript property in a dynamic way. Let\'s say I pass an argument to a function like this:

filter: functi         


        
3条回答
  •  迷失自我
    2021-01-27 12:48

    Maybe this way?

    filter: function(items) {
        var whatToFilter = items + 'ToFilter';
        this[whatToFilter].splice(index, 1);
    },
    

提交回复
热议问题