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ディレクトリで構文を直接使用できます。
ヒント: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);
});
Lightings.get(url[,data,[オプション]])
Lightings.post(url[,data,[オプション]])
Lightings.jsonp(url[,data,[オプション]])
注記:
config:true
プロパティを渡す必要があります。 lightings.get('test.json',{
config:true,
...
});
timeout
、 progress
をサポートしていませんoptions
(設定可能項目)timeout
設定項目を追加します。 (jsonp はタイムアウトをサポートしていません)progress
設定項目を追加します。 (jsonp はタイムアウトをサポートしていません)低ブラウザのPromise
機能を修正
照明 API を変更し、一部の古い設定を廃止します
最適化されたテンプレートのレンダリング