我正在尝试做一些我认为应该足够简单的事情。我在 ST2.1 中使用 datepickerfield
并尝试设置开始日期。我知道我可以这样设置年份:
{
xtype: 'datepickerfield',
picker: {
yearFrom: newDate().getFullYear(),
yearTo: 1930
}
}
但我还希望能够设置开始日期和月份。这可能吗?上面的结果类似于“2013 年 1 月 1 日”,这不是我想要的。
最佳答案
如果您只想设置选择器的初始日期,那么您只需要选择器的 value
配置属性即可。
{
xtype: 'datepickerfield',
value: (new Date()), // the value in the actual input (will also be in the picker UI)
picker: {
value: (new Date()), // use this if you DON'T want/have a value in the actual input
yearFrom: (new Date()).getFullYear(),
yearTo: 1930
}
}
在 documentation 中阅读更多内容(特别是“值”和“选择器”配置选项)。这是一个Sencha Fiddle演示用法。
关于datepicker - 如何在 sencha touch 2 的 datepickerfield 中设置从 'day' 和 'month',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15444369/