S
S
shasoft2019-03-05 14:29:12
Vue.js
shasoft, 2019-03-05 14:29:12

How to get Vue values?

I looked in the validator , where the rules are set in the form

import { required, minLength, between } from 'vuelidate/lib/validators'

export default {
  data () {
    return {
      name: '',
      age: 0
    }
  },
  validations: {
    name: {
      required,
      minLength: minLength(4)
    },
    age: {
      between: between(20, 30)
    }
  }
}

I'm trying to set my parameters in the same way, but I don't see the validations field in the Vue component
created: function() {
    // `this` указывает на экземпляр vm
    console.log("svalidations", this.svalidations);
  },
  beforeCreate: function() {
    console.log("beforeCreated.svalidations", this.svalidations);
  },
  svalidations: {
    email: "email",
    pass: "min:3"
  },

How to get these values? I would not want to shove them into data

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shasoft, 2019-03-05
@shasoft

Look for values ​​in options

beforeCreate: function() {
    // `this` указывает на экземпляр vm
    this.$svalidations = this.$options.svalidations;
    console.log("beforeCreated.svalidations", this.$options.svalidations);
  },

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question