3

My script like this :

===========--=========--=============--===============

<template> 
  <v-card
    max-width="1200"
    class="mx-auto"
  >
      <v-row>
        <v-col cols="12" sm="6" md="4">
          <v-menu
            ref="menu"
            v-model="menu"
            :close-on-content-click="false"
            :return-value.sync="date"
            transition="scale-transition"
            offset-y
            min-width="290px"
          >
            <template v-slot:activator="{ on }">
              <v-text-field
                v-model="date"
                label="Picker in menu"
                prepend-icon="event"
                readonly
                v-on="on"
              ></v-text-field>
            </template>
            <v-date-picker v-model="date" no-title scrollable>
              <div class="flex-grow-1"></div>
              <v-btn text color="primary" @click="menu = false">Cancel</v-btn>
              <v-btn text color="primary" @click="$refs.menu.save(date)">OK</v-btn>
            </v-date-picker>
          </v-menu>
        </v-col>
      </v-row>
  </v-card>
</template>
<script>
  export default {
    data: () => ({
      date: new Date().toISOString().substr(0, 10),
      menu: false,
      modal: false,
      menu2: false,
    }),
  }
</script>

The result like this : image1

it works. but I want to change that. I want the datepicker to appear when clicking a button like this : image2

How can I do it?

2 Answers 2

1

In your script, replace

<v-text-field
   v-model="date"
   label="Picker in menu"
   prepend-icon="event"
   readonly
   v-on="on"></v-text-field>

with

<v-btn v-on="on">CALL DATEPICKER</v-btn>
Sign up to request clarification or add additional context in comments.

Comments

0

You may try this solution.

<v-text-field
v-model="date"
label="Picker in menu"
prepend-icon="event"
readonly
>
 <template v-slot:append-outer>
  <v-btn
  icon
  color="indigo"
  v-bind="attrs"
  v-on="on"
  >
   <v-icon>mdi-calendar</v-icon>
  </v-btn>
 </template>

</v-text-field>

Note: You may need to add attrs here <template v-slot:activator="{ on }">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.