mengxiong10 / vue-datepicker-next

A datepicker / datetimepicker component for Vue3
https://mengxiong10.github.io/vue-datepicker-next/
MIT License
149 stars 35 forks source link

[Question] Import vue-datepicker-next via VITE #26

Open dukkevin opened 2 years ago

dukkevin commented 2 years ago

Vue-datepicker-next version: vue-datepicker-next Vue version: v3 Browser: Google Chrome / Version 105.0.5195.127

It is possible to import vue-datepicker-next via VITE? I used npm install vue-datepicker-next --save, then I imported in vite.config.js like import DatePicker from 'vue2-datepicker'; but is not working. Is there any other way of doing it?

vite.config.js

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import moment from 'moment';
import DatePicker from "vue2-datepicker";

export default defineConfig({
    plugins: [
        laravel([
            'resources/css/appErp.css',
            'resources/css/appSite.css',
            'resources/js/appErp.js',
            'resources/js/appSite.js',
        ]),
    ],
});

package.json

{
    "private": true,
    "scripts": {
        "dev": "vite",
        "build": "vite build"
    },
    "devDependencies": {
        "axios": "^0.25",
        "laravel-vite-plugin": "^0.2.1",
        "lodash": "^4.17.19",
        "moment": "^2.29.4",
        "postcss": "^8.1.14",
        "sass": "^1.53.0",
        "vite": "^2.9.11",
        "vue2-datepicker": "^3.11.0"
    },
    "dependencies": {
        "@fortawesome/fontawesome-free": "^6.1.1",
        "@popperjs/core": "^2.11.5",
        "bootstrap": "^5.1.3",
        "bootstrap-icons": "^1.9.0"
    }
}

in myfile.blade.php <date-picker valueType="format"></date-picker>

After running npm run build, everything is ok, I have no errors.

Desktop: OS: Windows 10 Browser: Chrome Version 103.0.5060.134 Version Laravel: 9.19 Version moment: 2.29.4

mengxiong10 commented 2 years ago

use <srcipt src="....vue2-datepicker">