1、到官網下載laydate.js
https://www.layui.com/laydate/
2、下載好后,將包解壓好放在index.html同級的地方。我是在public中建立個statick文件夾,放在了里面
3、在index.html中引入
<script src="./static/laydate/layDate-v5.0.9/laydate/laydate.js"></script>
4、在vue組件中使用
<template> <div class="main"> <input id="test" class="form-control layer-date" placeholder="YYYY-MM-DD hh:mm:ss" v-model="date"> <label class="laydate-icon"></label> </div> </template> <script> export default { data(){ return{ date: '2017-09-08 09:00:00', } }, mounted(){ console.log(laydate) laydate.render({ elem: '#test', type:'datetime', done: (value) => { this.date = value; console.log(this.date); } }) }, methods:{ } } </script> <style lang="less" scoped> </style>