Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                             <v-flex xs12 sm4>
  2.                                 <v-dialog
  3.                                     ref="dialog"
  4.                                     v-model="modal"
  5.                                     :return-value.sync="date"
  6.                                     persistent
  7.                                     lazy
  8.                                     full-width
  9.                                     width="290px"
  10.                                   >
  11.                                     <v-text-field
  12.                                       slot="activator"
  13.                                       v-model="computedDateFormatted"
  14.                                       label="Data do Evento"
  15.                                       prepend-icon="event"
  16.                                       readonly
  17.                                     ></v-text-field>
  18.  
  19.                                     <v-date-picker v-model="date" locale="pt-BR">
  20.                                       <v-spacer></v-spacer>
  21.                                       <v-btn flat color="primary" @click="modal = false">Cancelar</v-btn>
  22.                                       <v-btn flat color="primary" @click="$refs.dialog.save(date)">OK</v-btn>
  23.                                     </v-date-picker>
  24.  
  25.                                 </v-dialog>
  26.                             </v-flex>
  27.  
  28.  
  29.  data() {
  30.         return {
  31.          
  32.             date:null,
  33.             modal:false,
  34.         }
  35.    },
  36.  
  37.  
  38.  
  39.     computed: {
  40.  
  41.         computedDateFormatted () {
  42.             return this.formatDateToBr(this.date)
  43.         },
  44.  
  45.     },
  46.  
  47.  
  48.  
  49.     watch:{
  50.  
  51.      
  52.         date (val) {
  53.             this.dateFormatted = this.formatDateToBr(this.date);
  54.         },
  55.  
  56.  
  57.     },
  58.  
  59.  
  60.     methods: {
  61.    
  62.  
  63.         formatDateToBr (date) {
  64.             if (!date) return null
  65.  
  66.             const [year, month, day] = date.split('-')
  67.             return `${day}/${month}/${year}`
  68.         },
  69.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement