File tree Expand file tree Collapse file tree 2 files changed +51
-5
lines changed Expand file tree Collapse file tree 2 files changed +51
-5
lines changed Original file line number Diff line number Diff line change 23
23
- [ off] ( #off )
24
24
25
25
## 基本用法
26
+ 只需三步即可完成:
27
+ 1 . 引入 css 和 js;
28
+
29
+ 2 . 创建一个容器 ` div ` ,注意:这个容器必须是有宽度和高度(如 100% 或者 650px);
30
+ ``` html
31
+ <div class =" outer-container" ></div >
32
+ ```
33
+
34
+ 3 . 准备数据,创建 swiper。
26
35
``` javascript
27
36
var list = [{
37
+ content: ' <h1>第 0 页</h1>'
38
+ }, {
28
39
content: ' <h1>第 1 页</h1>'
29
40
}, {
30
41
content: ' <h1>第 2 页</h1>'
31
- }, {
32
- content: ' <h1>第 3 页</h1>'
33
- }]
42
+ }];
34
43
35
44
var swiper = new Swiper ({
36
- container: document .querySelector (' body ' ),
37
- data: list
45
+ container: document .querySelector (' .outer-container ' ),
46
+ data: list
38
47
});
39
48
```
49
+ 具体可以参考 [ example.html] ( https://github.com/fex-team/swiper/blob/master/example.html )
40
50
41
51
## 数据类型
42
52
Swiper 定义了两个数据类型: ` Transition ` 和 ` Page ` ,` Transition ` 用于描述翻页过渡动画,` Page ` 用于描述页面。
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
+ < meta http-equiv ="X-UA-Compatible " content ="ie=edge ">
7
+ < title > Swiper Example</ title >
8
+ < link rel ="stylesheet " href ="./dist/swiper.css ">
9
+ < style >
10
+ /* 容器需要有宽高 */
11
+ html , body , # outer-container {
12
+ height : 100% ;
13
+ width : 100% ;
14
+ }
15
+ </ style >
16
+ </ head >
17
+ < body >
18
+ < div id ="outer-container "> </ div >
19
+
20
+ < script src ="./dist/swiper.js "> </ script >
21
+ < script >
22
+ var list = [ {
23
+ content : '<h1>第 0 页</h1>'
24
+ } , {
25
+ content : '<h1>第 1 页</h1>'
26
+ } , {
27
+ content : '<h1>第 2 页</h1>'
28
+ } ]
29
+
30
+ var swiper = new Swiper ( {
31
+ container : document . querySelector ( '#outer-container' ) ,
32
+ data : list
33
+ } ) ;
34
+ </ script >
35
+ </ body >
36
+ </ html >
You can’t perform that action at this time.
0 commit comments