lightings
1.0.0
중국어문예 | 영어
ES6 Promise
기반으로 하는 경량 Ajax 프레임워크로 템플릿 렌더링을 지원합니다.
npm install lightings
lightings
|---src
| |---lightings.js (es6 source)
| |---promise.js (low browser support Promise)
|
|---dist
|---lightings.js (use bable compiler source code es5)
|---lightings.min.js
팁 :브라우저가 ES6 구문을 지원하는 경우 ES6 소스 코드의 src 디렉터리에서 직접 사용할 수 있습니다.
Tip :JSON 데이터의 통일된 사용 예:
{
"name": "Lightings",
"author": {
"firstName": "Jay",
"lastName": "Zangwill"
}
}
GET 요청 수행(템플릿 렌더링 사용)
lightings.get('test.json',{
config: true,
el: '#app'
}).then(function(data){
console.log(data);
//other operation
}).catch(function(error){
console.log(error);
});
<!-- html -->
<div id="app">
<p>author: {{author.firstName}} {{author.lastName}}</p>
<p>name: {{name}}</p>
</div>
GET 요청 수행(템플릿 렌더링을 사용하지 않음)
lightings.get('test.json')
.then(function(data){
console.log(data);
//dom operation and other operation
}).catch(function(error){
console.log(error);
});
교차 도메인 요청
lightings.jsonp('http://jayzangwill.cn/test.json')
.then(function(data){
console.log(data);
//dom operation and other operation
}).catch(function(error){
console.log(error);
});
조명.get(url[,data,[옵션]])
조명.포스트(url[,data,[옵션]])
조명.jsonp(url[,data,[옵션]])
메모 :
config:true
속성을 전달해야 합니다. lightings.get('test.json',{
config:true,
...
});
timeout
, progress
지원하지 않습니다. options
(구성 가능 항목)timeout
구성 항목을 추가합니다. (jsonp는 시간 초과를 지원하지 않습니다)progress
구성 항목을 추가합니다. (jsonp는 시간 초과를 지원하지 않습니다) 낮은 브라우저 Promise
기능 수정
조명 API 수정, 일부 오래된 구성 폐지
최적화된 템플릿 렌더링