0
 public List<SelectOption> getYearList(){

    Integer year =  Date.Today().year();
    String s1=string.valueof(year).right(2);
    Integer Year1= Integer.valueof(s1);
    List<SelectOption> YearListOptions = new List<SelectOption>();
    YearListOptions .add(new SelectOption('','YY'));
    for(Integer i=Year1;i<=Year1+8;i++)
    {
       string j=string.valueof(i);

        YearListOptions .add(new SelectOption(j,j));

    }
    return YearListOptions ;
}

我试过了,但是像 AuraEnabled 方法一样出现错误不支持 List 的返回类型

4

1 回答 1

0

我已经改变了这个,但任何人有任何建议或意见,请随时添加

@AuraEnabled   
public List<String> getYearList(){
    Integer year =  Date.Today().year();
    String s1=string.valueof(year).right(2);
    Integer Year1= Integer.valueof(s1);
    List<SelectOption> YearListOptions = new List<SelectOption>();
    List<String> yearValueList = new List<String>();
    YearListOptions .add(new SelectOption('','YY'));
    for(Integer i=Year1;i<=Year1+8;i++)
    {
        string j=string.valueof(i);
        YearListOptions .add(new SelectOption(j,j));
    }
    for (SelectOption sO : YearListOptions){
        yearValueList.add(sO.getValue());
    }
    return yearValueList ;
}
于 2020-05-29T07:07:02.097 回答