0

I have a minimal Vue app:


<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>
    <meta http-equiv='x-ua-compatible' content='ie=edge'>
    <!-- 1. Link Vue Javascript -->
    <script src='https://unpkg.com/vue/dist/vue.js'></script>

    <!-- 2. Link VCalendar Javascript (Plugin automatically installed) -->
    <script src='https://unpkg.com/v-calendar'></script>
    <!--3. Create the Vue instance-->
    <script>
        window.onload = function(){            
            new Vue({
                el: '#app',
                data: {                    
                },
                template: ''
            })
        }
      </script>
  </head>
  <body>
    <div id='app'>
    </div>
  </body>
</html>

and I want to show the date picker from https://vcalendar.io/examples/datepickers.html#button-dropdown but is only specified as template.

What are the steps to display that date picker inside my application?

1

1 Answer 1

1

new Vue({
  el: '#app',
  data: () => ({
    selectedDate: null
  }),
  template: `
  <div>    
    <v-date-picker class="inline-block" v-model="selectedDate">
    <template v-slot="{ inputValue, togglePopover }">
      <div class="flex items-center">
        <button @click="togglePopover()">
          Pick date
        </button>
        <input
          :value="inputValue"          
          readonly
        />
      </div>
    </template>
  </v-date-picker>
  </div>
  `
})
<!-- 1. Link Vue Javascript -->
<script src='https://unpkg.com/vue/dist/vue.js'></script>
<!-- 2. Link VCalendar Javascript (Plugin automatically installed) -->
<script src='https://unpkg.com/v-calendar'></script>

<div id='app'>
</div>

Sign up to request clarification or add additional context in comments.

3 Comments

Close but I do not see the actual pick button
This is example of how to use template. Put inside whatever you want...
So the key was the fact that the top most 'template' definition (found at vcalendar.io/examples/datepickers.html#button-dropdown) was actually Vue's main 'template'

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.