Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- props: {
- maxLength: { type: Number, default: 20 },
- }
- i18n: {messages: {
- en: { name_length: "Max. {this.maxLength} characters" },...
- }
- "Max." + String(this.maxLength) + characters", but it comes out as undefined.
- v-model="text" :prepend-icon="iconfront"
- :rules="nameRules" :name="name"
- :label="label" :type="type">
- </v-text-field>
- </template>
- <script>
- export default {
- props: {
- value: {type: String},
- iconfront: { type: String },
- name: { type: String },
- label: { type: String },
- type: { type: String, default: 'text' },
- minLength: { type: Number, default: 1 },
- maxLength: { type: Number, default: 20 },
- },
- computed: {
- text: { get() { return this.value },
- set(val) { this.$emit('input', val) }
- }
- },
- data () {
- return {
- nameRules: [
- (v) => !!v || this.$i18n.t("name_rule"),
- (v) => v && v.length <= this.maxLength || this.$i18n.t("name_length")
- ]
- }
- },
- methods: {
- onInput(input){
- this.$emit('textFieldInput', input)
- }
- },
- i18n: {
- messages: {
- en: {
- name_rule: "required field",
- **name_length: "Max. {this.maxLength} characters",**
- confirmation_rule: "passwords must match",
- email_rule: "email must be valid",
- password_length: "Length must be" + String(this.minLength)+ "-" + String(this.minLength) + "characters",
- },
- de: {
- name_rule: "Pflichtfeld",
- name_length: "Max. 20 Zeichen",
- confirmation_rule: "Passwörter müssen übereinstimmen",
- email_rule: "Email muss gültig sein",
- password_length: "Länge: 6-20 Zeichen",
- },
- fr: {
- name_rule: "champs requis",
- name_length: "20 caractères maximum",
- confirmation_rule: "les mots de passe doivent correspondre",
- email_rule: "email doit être valide",
- password_length: "longueur requise: 6 à 20 caractères",
- },
- }
- }, //end of translations
- }
- </script>
Add Comment
Please, Sign In to add comment