Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimePanel error with moment format and type datetime #377

Closed
Domenico-Pirozzi opened this issue Nov 21, 2019 · 3 comments
Closed

TimePanel error with moment format and type datetime #377

Domenico-Pirozzi opened this issue Nov 21, 2019 · 3 comments

Comments

@Domenico-Pirozzi
Copy link

Vue2-datepicker version: 3.0.2
Vue version: 2.6.10
Browser: all

DatePicker set with both type="datetime" and custom moment format raises the following error after selecting date and before opening TimePanel:

[Vue warn]: Invalid prop: type check failed for prop "format". Expected String with value "[object Object]", got Object

I don't get any errors when using format and type="date"

@Domenico-Pirozzi Domenico-Pirozzi changed the title [Bug] TimePanel error with moment format and type datetime Nov 21, 2019
@mengxiong10
Copy link
Owner

Thanks for feedback.
It's a bug.
You need to set the show-hour show-minute show-second now. Their default is false due to this bug.
I'll fix it, then the default value will be true and clear the warn.

<date-picker
        v-model="value4"
        :format="momentForamt"
        :show-hour="true"
        :show-minute="true"
        :show-second="true"
        type="datetime"
        placeholder="Select datetime"
      ></date-picker>

@Domenico-Pirozzi
Copy link
Author

Domenico-Pirozzi commented Nov 21, 2019

Thanks for feedback.
It's a bug.
You need to set the show-hour show-minute show-second now. Their default is false due to this bug.
I'll fix it, then the default value will be true and clear the warn.

<date-picker
        v-model="value4"
        :format="momentForamt"
        :show-hour="true"
        :show-minute="true"
        :show-second="true"
        type="datetime"
        placeholder="Select datetime"
      ></date-picker>

Thanks a lot for the quick reply, I'll try your solution.
In the meantime I also found this solution:

<DatePicker
  v-model="date"
  input-class="form-control"
  valueType="YYYY-MM-DDTHH:mm:ss"
  type="datetime" 
  :format="dpFormat" 
></DatePicker>`
import DatePicker from "vue2-datepicker";
export default Vue.extend({
  name: "home",
  components: {
    DatePicker
  },
  data() {
    return {
      dpFormat: `${moment.localeData().longDateFormat('L')} ${moment.localeData().longDateFormat('LT')}`
    };
  }
});

@mengxiong10
Copy link
Owner

fixed in v3.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants