|
25 | 25 | { |
26 | 26 | url: 'http://www.didichuxing.com/', |
27 | 27 | image: '//webapp.didistatic.com/static/webapp/shield/cube-ui-examples-slide01.png' |
28 | | - }, { |
| 28 | + }, |
| 29 | + { |
29 | 30 | url: 'http://www.didichuxing.com/', |
30 | 31 | image: '//webapp.didistatic.com/static/webapp/shield/cube-ui-examples-slide02.png' |
31 | | - }, { |
| 32 | + }, |
| 33 | + { |
32 | 34 | url: 'http://www.didichuxing.com/', |
33 | 35 | image: '//webapp.didistatic.com/static/webapp/shield/cube-ui-examples-slide03.png' |
34 | 36 | } |
|
46 | 48 | } |
47 | 49 | ``` |
48 | 50 |
|
| 51 | +- 初始索引 |
| 52 | + |
| 53 | + 初始化时展示的位置索引值,默认为 0。 |
| 54 | + |
| 55 | + ```html |
| 56 | + <cube-slide :initial-index="1"></cube-slide> |
| 57 | + ``` |
| 58 | + |
49 | 59 | - 循环播放 |
50 | 60 |
|
51 | 61 | 默认开启循环播放,可通过 loop 属性配置。 |
52 | 62 |
|
53 | 63 | ```html |
54 | | - <cube-slide></cube-slide> |
55 | 64 | <cube-slide :loop="false"></cube-slide> |
56 | 65 | ``` |
57 | 66 |
|
|
60 | 69 | 默认开启自动播放,可通过 auto-play 属性配置。 |
61 | 70 |
|
62 | 71 | ```html |
63 | | - <cube-slide></cube-slide> |
64 | 72 | <cube-slide :auto-play="false"></cube-slide> |
65 | 73 | ``` |
66 | 74 |
|
|
78 | 86 |
|
79 | 87 | ```html |
80 | 88 | <cube-slide :threshold="0.4"></cube-slide> |
| 89 | + ``` |
81 | 90 |
|
82 | 91 | - 切换页面的速度 |
83 | 92 |
|
|
87 | 96 | <cube-slide :speed="200"></cube-slide> |
88 | 97 | ``` |
89 | 98 |
|
| 99 | +- refresh 方法 |
| 100 | + |
| 101 | + 当新增或者删除 Slide Item 项或者修改 Slide 配置的时候,可以调用实例的 refresh 方法更新 Slide。 |
| 102 | + |
| 103 | + ```html |
| 104 | + <cube-slide ref="slide"> |
| 105 | + <cube-slide-item v-for="(item, index) in items" :key="index"> |
| 106 | + <a :href="item.url"> |
| 107 | + <img :src="item.image"> |
| 108 | + </a> |
| 109 | + </cube-slide-item> |
| 110 | + </cube-slide> |
| 111 | + ``` |
| 112 | + ```js |
| 113 | + const item3 = { |
| 114 | + url: 'http://www.didichuxing.com/', |
| 115 | + image: '//webapp.didistatic.com/static/webapp/shield/cube-ui-examples-slide03.png' |
| 116 | + } |
| 117 | + export default { |
| 118 | + data() { |
| 119 | + return { |
| 120 | + items: [ |
| 121 | + { |
| 122 | + url: 'http://www.didichuxing.com/', |
| 123 | + image: '//webapp.didistatic.com/static/webapp/shield/cube-ui-examples-slide01.png' |
| 124 | + }, |
| 125 | + { |
| 126 | + url: 'http://www.didichuxing.com/', |
| 127 | + image: '//webapp.didistatic.com/static/webapp/shield/cube-ui-examples-slide02.png' |
| 128 | + } |
| 129 | + ] |
| 130 | + } |
| 131 | + }, |
| 132 | + mounted() { |
| 133 | + setTimeout(() => { |
| 134 | + this.items.push(item3) |
| 135 | + this.$refs.slide.refresh() |
| 136 | + }, 2000) |
| 137 | + } |
| 138 | + } |
| 139 | + ``` |
| 140 | + |
| 141 | + 延迟 2 秒钟后新增一个 Slide Item,新增完成后需要调用 refresh 方法更新。 |
| 142 | + |
| 143 | +- 修改 dots 内容 |
| 144 | + |
| 145 | + 默认是点,可通过插槽修改。 |
| 146 | + |
| 147 | + ```html |
| 148 | + <cube-slide> |
| 149 | + <template slot="dots" slot-scope="props"> |
| 150 | + <span class="my-dot" :class="{active: props.current === index}" v-for="(item, index) in props.dots">{{index + 1}}</span> |
| 151 | + </template> |
| 152 | + </cube-slide> |
| 153 | + ``` |
| 154 | + |
| 155 | + 作用域插槽提供了所需的当前索引值 `current` 以及长度 `dots`。 |
| 156 | + |
90 | 157 | ### Props 配置 |
91 | 158 |
|
92 | 159 | | 参数 | 说明 | 类型 | 可选值 | 默认值 | |
93 | 160 | | - | - | - | - | - | |
| 161 | +| initialIndex | 初始索引值 | Number | - | 0 | |
94 | 162 | | loop | 是否循环播放 | Boolean | true/false | true | |
95 | 163 | | autoPlay | 是否自动播放 | Boolean | true/false | true | |
96 | 164 | | interval | 播放间隔 | Number | - | 4000 | |
97 | 165 | | threshold | 切换页面的滑动阈值 | Number | (0, 1) | 0.3 | |
98 | 166 | | speed | 切换页面的速度 | Number | - | 400 | |
99 | 167 |
|
| 168 | +### 插槽 |
| 169 | + |
| 170 | +| 名字 | 说明 | 作用域参数 | |
| 171 | +| - | - | - | |
| 172 | +| default | 默认内容,由 cube-slide-item 构成 | - | |
| 173 | +| dots | dots 内容 | dots: 轮播项长度 <br> current: 当前索引 | |
| 174 | + |
100 | 175 | ### 事件 |
101 | 176 |
|
102 | 177 | | 事件名 | 说明 | 参数 | |
|
0 commit comments