[英]Use ion-datetime v4 instead of v6
I am working on an ionic project that was primarily built using v4 of the ionic framework.我正在开发一个主要使用离子框架 v4 构建的离子项目。 After a recent change in my system setup I'm not able to display my datetime component as it was under ionic v4
最近更改了我的系统设置后,我无法显示我的日期时间组件,因为它在 ionic v4 下
I would like to display my date time as following:我想显示我的日期时间如下:
Instead of what it is now:而不是现在的样子:
How to force ionic to use v4 component instead of v6?如何强制 ionic 使用 v4 组件而不是 v6?
After looking for a good idea and keeping the version of ionic, you can use the multipicker as a date picker, I know it's not the best solution, but is the closer way to do it with the same view, here is an example of day - month picker在寻找一个好主意并保留 ionic 的版本之后,您可以使用 multipicker 作为日期选择器,我知道这不是最好的解决方案,但是在相同的视图下更接近的方法,这里是一天的例子- 月份选择器
Put in your html:放入您的 html:
<ion-item>
<ion-input type="">{{pdate}}</ion-input>
</ion-item>
<ion-button expand="block" (click)="presentPicker()">Show Picker</ion-button>
Put in your controller:放入您的 controller:
private pdate: string;
constructor(private pickerController: PickerController) { }
...
async presentPicker() {
const picker = await this.pickerController.create({
buttons: [
{
text: 'Confirm',
handler: (selected) => {
this.pdate = selected.day.value +selected.month.value ;
},
}
],
columns: [
{
name: 'day',
options: [
{ text: '01', value: '01' },
{ text: '02', value: '02' },
{ text: '03', value: '03' },
]
},
{
name: 'month',
options: [
{ text: 'Jan', value: '01' },
{ text: 'Feb', value: '02' },
{ text: 'Mar', value: '03' },
]
}
]
});
await picker.present();
} }
you need to install ionic v4 follow this command您需要按照此命令安装 ionic v4
npm install -g ionic@5.0.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.