我正在尝试对我的模型进行排序。但是得到错误
Cannot read property 'sort' of undefined
任何人帮我解决这个问题?我想model
方法中不存在Computed
。
这是我的代码:
import Ember from 'ember';
export default Ember.Route.extend({
model(){
return [{"name":"fruit"},{"name":"flowers"}]
},
sortingByKey:['date'],
sorter:Ember.Computed.sort("model","sortingByKey"),
init(){
var sort = this.get("sorter");
}
});
答案 0 :(得分:1)
应该是import java.util.*;
public class Nails
{
public static void main(String[] args)
{
Scanner i = new Scanner(System.in);
String[][] comms = { { "ACac", "CAca" }, { "ADad", "DAda" }, { "AEae", "EAea" }, { "AFaf", "FAfa" },
{ "AGag", "GAga" }, { "AHah", "HAha" }, { "AIai", "Iaia" }, { "AJaj", "JAja" }, { "AKak", "KAka" },
{ "ALal", "LAla" }, { "AMam", "MAma" }, { "ANan", "NAna" }, { "AOao", "OAoa" }, { "APap", "PApa" },
{ "AQaq", "QAqa" }, { "ARar", "RAra" }, { "ASas", "SAsa" }, { "ATat", "TAta" }, { "AUau", "UAua" },
{ "AVav", "VAva" }, { "AWaw", "WAwa" }, { "AXax", "XAxa" }, { "AYay", "YAya" }, { "AZaz", "ZAza" } };
String Master = "ABab";
String S = Master; //Slave String
String Tmp = S;
System.out.println("Amount of Nails: ");
int N = i.nextInt(); //Nails
if(N < 2)
{
System.out.println("Sorry, You Must input a number Greater than or Equal to 2");
}
if(N == 2)
{
System.out.println(Master);
}
else
{
for(int c = 0; c < N - 2; c++) //C for Counter, subtracting 2 because method wont run if it is <= 2 and 'Comms' starts on 0 which would be 3 Nails
{
System.out.println(S);
S = S.replace("A", Comms[c][0]);
S = S.replace("a", Comms[c][1]);
System.out.println(S);
}
}
}
}
而不是Ember.computed
。错误说Ember.Computed
未定义。
在您的代码中存在一些问题,
1. Ember.Computed
属性将在控制器中可用(将由setupController设置
2.你不能在model
中这样做
3. this.get("sorter")
date
属性