Search code examples
htmlvue.jsmaterialize

Vue.js materialize datepicker not showing


I am using materialize in my Vue.js project I am having issues with displaying materialize's datepicker this is the code i have.

<form class="form">
...
    <input type="text" class="datepicker" />
</form>

 data() {
    return {
      date: null
    };
  },
  mounted() {
    $(document).ready(function() {
      $(".datepicker").datepicker();
    });
  }

I am new to Vue.js so I apologize for the simplicity of my question So how do i get the datepicker to display and save it to a variable I have had the issue with materialize not displaying tabs properly also i don't know if i don't have something imported correctly. this is my html file.

<head>
  <!--Import Google Icon Font-->
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <!-- Compiled and minified CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
</head>
<body>
...
 <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>   
 <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js"></script>
 </script>
</body>

Solution

  • Looks like you forgot to load Materialize after jQuery.

      <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>