动态key的调用方法

Call method of dynamic key

这是我的数据对象:

registration: {
        step1: {
          project: '',
        },
        step2: {
          adres: '',
          facade: '',
          floor: '',
        },
      },

我正尝试使用单个函数验证用户输入,如下所示:

validateStep(stepNumber) { 
    const self = this; 
    const step = step${stepNumber}; 
    console.log(step); 
    this.$v.registration[${step}].touch(); 
    if (this.$v.registration[${step}].$error) { 
      this.$q.notify('Controleer aub de velden opnieuw'); 
      return; 
    } 

    self.$refs.stepper.next();
}

但这给出了这个错误:

TypeError: this.$v.registration["".concat(...)].touch is not a function

我也这样试过:

validateStep(stepNumber) {
      const self = this;
      const step = `step${stepNumber}`;
      console.log(this.$v.registration[step]); //this prints the correct object
      const currentStep = this.$v.registration[step];
      currentStep.touch();

      if (currentStep.$error) {
        this.$q.notify('Controleer aub de velden opnieuw');
        return;
      }
      self.$refs.stepper.next();
    },

我做错了什么?

Vuelidate 方法应该是 $touch 而不是 touch