CANJS 문서를 통해 can.List()에 정렬 함수를 구현하려고했습니다.CANJS sort() 함수 사용 방법
var list = new can.List([
{ name: 'Justin' },
{ name: 'Brian' },
{ name: 'Austin' },
{ name: 'Mihael' }])
list.comparator = 'name';
list.sort(); //- sorts the list by the name attribute
콘솔 (브라우저)에서 실행하려고했을 때. 그것은 "Uncaught TypeError : undefined가 함수가 아닙니다"라고 말합니다. 왜? 내가 여기서 뭔가를 놓치고 있니?
참조 : http://canjs.com/docs/can.List.prototype.sort.html
감사합니다 :) 플러그인을 콘솔에 추가하려면 다음을 추가하십시오. var script = document.createElement ('script'); script.src = 'http://canjs.com/release/latest/can.list.sort.js'; document.getElementsByTagName ('head') [0] .appendChild (script); – Jry9972
또는 jQuery가 이미로드 된 경우 :''$ ('head'). append ("") " –