Guest User

Untitled

a guest
Jul 23rd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. props: {
  2. maxLength: { type: Number, default: 20 },
  3. }
  4.  
  5. i18n: {messages: {
  6. en: { name_length: "Max. {this.maxLength} characters" },...
  7.  
  8. }
  9.  
  10. "Max." + String(this.maxLength) + characters", but it comes out as undefined.
  11.  
  12. v-model="text" :prepend-icon="iconfront"
  13. :rules="nameRules" :name="name"
  14. :label="label" :type="type">
  15.  
  16. </v-text-field>
  17.  
  18. </template>
  19.  
  20. <script>
  21.  
  22. export default {
  23.  
  24. props: {
  25. value: {type: String},
  26. iconfront: { type: String },
  27. name: { type: String },
  28. label: { type: String },
  29. type: { type: String, default: 'text' },
  30. minLength: { type: Number, default: 1 },
  31. maxLength: { type: Number, default: 20 },
  32. },
  33. computed: {
  34. text: { get() { return this.value },
  35. set(val) { this.$emit('input', val) }
  36. }
  37. },
  38. data () {
  39. return {
  40. nameRules: [
  41.  
  42. (v) => !!v || this.$i18n.t("name_rule"),
  43. (v) => v && v.length <= this.maxLength || this.$i18n.t("name_length")
  44.  
  45. ]
  46. }
  47. },
  48. methods: {
  49. onInput(input){
  50. this.$emit('textFieldInput', input)
  51. }
  52. },
  53. i18n: {
  54. messages: {
  55. en: {
  56. name_rule: "required field",
  57. **name_length: "Max. {this.maxLength} characters",**
  58. confirmation_rule: "passwords must match",
  59. email_rule: "email must be valid",
  60. password_length: "Length must be" + String(this.minLength)+ "-" + String(this.minLength) + "characters",
  61. },
  62. de: {
  63. name_rule: "Pflichtfeld",
  64. name_length: "Max. 20 Zeichen",
  65. confirmation_rule: "Passwörter müssen übereinstimmen",
  66. email_rule: "Email muss gültig sein",
  67. password_length: "Länge: 6-20 Zeichen",
  68. },
  69. fr: {
  70. name_rule: "champs requis",
  71. name_length: "20 caractères maximum",
  72. confirmation_rule: "les mots de passe doivent correspondre",
  73. email_rule: "email doit être valide",
  74. password_length: "longueur requise: 6 à 20 caractères",
  75.  
  76. },
  77. }
  78. }, //end of translations
  79. }
  80.  
  81.  
  82. </script>
Add Comment
Please, Sign In to add comment