MahdadGhasemian / vue-datetime-js

A Vue.js datepicker component (gregory, jalali, hijri)
https://mahdadghasemian.github.io/vue-datetime-js/#/
7 stars 8 forks source link

component error while rendering #26

Closed omduiji closed 2 years ago

omduiji commented 2 years ago

Hello,

When I load the component for the first time it works properly, but when I select a date and close the calendar then opens it again it breaks up. <date-picker v-model="issueDate" :locale="'ar-sa'" :calendar="'hijri'" element="dateInput" :wrapper-submit="true" appendTo=".container" :auto-submit="true" inputFormat="'jYYYY/jMM/jDD HH:mm'" ></date-picker> ![calendar_err](https://user-images.githubusercontent.com/24576901/155442230-ae2a3381-6959-4244-b4b5-d1df66e2b149.PNG)

MahdadGhasemian commented 2 years ago

added following to vue.config.js file :

var webpack = require("webpack");

module.exports = defineConfig({

  configureWebpack: {
    plugins: [
      new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /moment$/)
    ],
  }
});

or try this : please install moment (npm install moment --save) and in main.js file insert this code in first of file:

import moment from 'moment';
moment.updateLocale('ar-sa', {
    postformat: function(string) {
        return string
            .replace(/\d/g, function(match) {
                return match;
            })
            .replace(/,/g, '،')
    }
})