forked from ElemeFE/element
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '1.1' into feat/scrollbar
- Loading branch information
Showing
39 changed files
with
1,985 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,189 @@ | ||
## carousel | ||
<script> | ||
export default { | ||
mounted() { | ||
this.$nextTick(() => { | ||
const demos = document.querySelectorAll('.source'); | ||
demos[0].style.padding = '0'; | ||
demos[0].className += ' small'; | ||
demos[3].className += ' medium'; | ||
}); | ||
} | ||
} | ||
</script> | ||
## Carousel | ||
|
||
Loop a series of images or texts in a limited space | ||
|
||
### Basic usage | ||
|
||
::: demo Combine `el-carousel` with `el-carousel-item`, and you'll get a carousel. Content of each slide is completely customizable, and you just need to place it inside `el-carousel-item` tag. By default the carousel switches when mouse hovers over an indicator. Set `trigger` to `click`, and the carousel switches only when an indicator is clicked. | ||
```html | ||
<template> | ||
<div class="block"> | ||
<span class="demonstration">Switch when indicator is hovered (default)</span> | ||
<el-carousel height="150px"> | ||
<el-carousel-item v-for="item in 4"> | ||
<h3>{{ item }}</h3> | ||
</el-carousel-item> | ||
</el-carousel> | ||
</div> | ||
<div class="block"> | ||
<span class="demonstration">Switch when indicator is clicked</span> | ||
<el-carousel trigger="click" height="150px"> | ||
<el-carousel-item v-for="item in 4"> | ||
<h3>{{ item }}</h3> | ||
</el-carousel-item> | ||
</el-carousel> | ||
</div> | ||
</template> | ||
|
||
<style> | ||
.el-carousel__item h3 { | ||
color: #475669; | ||
font-size: 14px; | ||
opacity: 0.75; | ||
line-height: 150px; | ||
margin: 0; | ||
} | ||
.el-carousel__item:nth-child(2n) { | ||
background-color: #99a9bf; | ||
} | ||
.el-carousel__item:nth-child(2n+1) { | ||
background-color: #d3dce6; | ||
} | ||
</style> | ||
``` | ||
::: | ||
|
||
### Indicators | ||
|
||
Indicators can be displayed outside the carousel | ||
|
||
::: demo The `indicator-position` attribute determines where the indicators are located. By default they are inside the carousel, and setting `indicator-position` to `outside` moves them outside; setting `indicator-position` to `none` hides the indicators. | ||
```html | ||
<template> | ||
<el-carousel indicator-position="outside"> | ||
<el-carousel-item v-for="item in 4"> | ||
<h3>{{ item }}</h3> | ||
</el-carousel-item> | ||
</el-carousel> | ||
</template> | ||
|
||
<style> | ||
.el-carousel__item h3 { | ||
color: #475669; | ||
font-size: 18px; | ||
opacity: 0.75; | ||
line-height: 300px; | ||
margin: 0; | ||
} | ||
.el-carousel__item:nth-child(2n) { | ||
background-color: #99a9bf; | ||
} | ||
.el-carousel__item:nth-child(2n+1) { | ||
background-color: #d3dce6; | ||
} | ||
</style> | ||
``` | ||
::: | ||
|
||
### Arrows | ||
|
||
You can define when arrows are displayed | ||
|
||
::: demo The `arrow` attribute determines when arrows are displayed. By default they appear when mouse hovers over the carousel. Setting `arrow` to `always` or `never` shows/hides the arrows permanently. | ||
```html | ||
<template> | ||
<el-carousel :interval="5000" arrow="always"> | ||
<el-carousel-item v-for="item in 4"> | ||
<h3>{{ item }}</h3> | ||
</el-carousel-item> | ||
</el-carousel> | ||
</template> | ||
|
||
<style> | ||
.el-carousel__item h3 { | ||
color: #475669; | ||
font-size: 18px; | ||
opacity: 0.75; | ||
line-height: 300px; | ||
margin: 0; | ||
} | ||
.el-carousel__item:nth-child(2n) { | ||
background-color: #99a9bf; | ||
} | ||
.el-carousel__item:nth-child(2n+1) { | ||
background-color: #d3dce6; | ||
} | ||
</style> | ||
``` | ||
::: | ||
|
||
### Card mode | ||
|
||
When a page is wide enough but has limited height, you can activate card mode for carousels | ||
|
||
::: demo Setting `type` to `card` activates the card mode. Apart from the appearance, the biggest difference between card mode and common mode is that clicking the slides at both sides directly switches the carousel in card mode. | ||
```html | ||
<template> | ||
<el-carousel :interval="4000" type="card" height="200px"> | ||
<el-carousel-item v-for="item in 6"> | ||
<h3>{{ item }}</h3> | ||
</el-carousel-item> | ||
</el-carousel> | ||
</template> | ||
|
||
<style> | ||
.el-carousel__item h3 { | ||
color: #475669; | ||
font-size: 14px; | ||
opacity: 0.75; | ||
line-height: 200px; | ||
margin: 0; | ||
} | ||
.el-carousel__item:nth-child(2n) { | ||
background-color: #99a9bf; | ||
} | ||
.el-carousel__item:nth-child(2n+1) { | ||
background-color: #d3dce6; | ||
} | ||
</style> | ||
``` | ||
::: | ||
|
||
### Carousel Attributes | ||
| Attribute | Description | Type | Accepted Values | Default | | ||
|---------- |-------------- |---------- |-------------------------------- |-------- | | ||
| height | height of the carousel | number | — | 300 | | ||
| initial-index | index of the initially active slide (starting from 0) | number | — | 0 | | ||
| trigger | how indicators are triggered | string | click | — | | ||
| autoplay | whether automatically loop the slides | boolean | — | true | | ||
| interval | interval of the auto loop, in milliseconds | number | — | 3000 | | ||
| indicator-position | position of the indicators | string | outside/none | — | | ||
| arrow | when arrows are shown | string | always/hover/never | hover | | ||
| type | type of the Carousel | string | card | — | | ||
|
||
### Events | ||
| Event Name | Description | Parameters | | ||
|---------|---------|---------| | ||
| change | triggers when the active slide switches | index of the new active slide, index of the old active slide | | ||
|
||
### Methods | ||
| Method | Description | Parameters | | ||
|---------- |-------------- | - | | ||
| setActiveItem | manually switch slide | index of the slide to be switched to, starting from 0; or the `name` of corresponding `el-carousel-item` | | ||
| prev | switch to the previous slide | — | | ||
| next | switch to the next slide | — | | ||
|
||
### Carousel-Item Attributes | ||
| Attribute | Description | Type | Accepted Values | Default | | ||
|---------- |-------------- |---------- |-------------------------------- |-------- | | ||
| name | name of the item, can be used in `setActiveItem` | string | — | — | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<script> | ||
export default { | ||
data() { | ||
return { | ||
activeNames: ['1'], | ||
activeName: '1' | ||
}; | ||
}, | ||
methods: { | ||
handleChange(val) { | ||
console.log(val); | ||
} | ||
} | ||
} | ||
</script> | ||
<style> | ||
.demo-collapse { | ||
.el-collapse-item__header { | ||
.header-icon { | ||
margin-left: 5px; | ||
} | ||
} | ||
} | ||
</style> | ||
|
||
## Collapse | ||
|
||
Use Collapse to storage content. | ||
|
||
### Basic usage | ||
|
||
可同时展开多个面板,面板之间不影响 | ||
|
||
:::demo | ||
```html | ||
<el-collapse v-model="activeNames" @change="handleChange"> | ||
<el-collapse-item title="Consistency" name="1"> | ||
<div>与现实生活一致:与现实生活的流程、逻辑保持一致,遵循用户习惯的语言和概念;</div> | ||
<div>在界面中一致:所有的元素和结构需保持一致,比如:设计样式、图标和文本、元素的位置等。</div> | ||
</el-collapse-item> | ||
<el-collapse-item title="Feedback" name="2"> | ||
<div>控制反馈:通过界面样式和交互动效让用户可以清晰的感知自己的操作;</div> | ||
<div>页面反馈:操作后,通过页面元素的变化清晰地展现当前状态。</div> | ||
</el-collapse-item> | ||
<el-collapse-item title="Efficiency" name="3"> | ||
<div>简化流程:设计简洁直观的操作流程;</div> | ||
<div>清晰明确:语言表达清晰且表意明确,让用户快速理解进而作出决策;</div> | ||
<div>帮助用户识别:界面简单直白,让用户快速识别而非回忆,减少用户记忆负担。</div> | ||
</el-collapse-item> | ||
<el-collapse-item title="Controllability" name="4"> | ||
<div>用户决策:根据场景可给予用户操作建议或安全提示,但不能代替用户进行决策;</div> | ||
<div>结果可控:用户可以自由的进行操作,包括撤销、回退和终止当前操作等。</div> | ||
</el-collapse-item> | ||
</el-collapse> | ||
<script> | ||
export default { | ||
data() { | ||
return { | ||
activeNames: ['1'] | ||
}; | ||
} | ||
} | ||
</script> | ||
``` | ||
::: | ||
|
||
### Accordion | ||
|
||
At the same time only one item can be opened. | ||
|
||
:::demo 通过 `accordion` 属性来设置是否以手风琴模式显示。 | ||
```html | ||
<el-collapse v-model="activeName" accordion> | ||
<el-collapse-item title="Consistency" name="1"> | ||
<div>与现实生活一致:与现实生活的流程、逻辑保持一致,遵循用户习惯的语言和概念;</div> | ||
<div>在界面中一致:所有的元素和结构需保持一致,比如:设计样式、图标和文本、元素的位置等。</div> | ||
</el-collapse-item> | ||
<el-collapse-item title="Feedback" name="2"> | ||
<div>控制反馈:通过界面样式和交互动效让用户可以清晰的感知自己的操作;</div> | ||
<div>页面反馈:操作后,通过页面元素的变化清晰地展现当前状态。</div> | ||
</el-collapse-item> | ||
<el-collapse-item title="Efficiency" name="3"> | ||
<div>简化流程:设计简洁直观的操作流程;</div> | ||
<div>清晰明确:语言表达清晰且表意明确,让用户快速理解进而作出决策;</div> | ||
<div>帮助用户识别:界面简单直白,让用户快速识别而非回忆,减少用户记忆负担。</div> | ||
</el-collapse-item> | ||
<el-collapse-item title="Controllability" name="4"> | ||
<div>用户决策:根据场景可给予用户操作建议或安全提示,但不能代替用户进行决策;</div> | ||
<div>结果可控:用户可以自由的进行操作,包括撤销、回退和终止当前操作等。</div> | ||
</el-collapse-item> | ||
</el-collapse> | ||
<script> | ||
export default { | ||
data() { | ||
return { | ||
activeName: '1' | ||
}; | ||
} | ||
} | ||
</script> | ||
``` | ||
::: | ||
|
||
### Customize Title | ||
|
||
除了可以通过 `title` 属性以外,还可以通过作用域插槽来实现自定义面板的标题内容,以实现增加图标等效果。 | ||
|
||
:::demo | ||
```html | ||
<el-collapse accordion> | ||
<el-collapse-item title="Consistency"> | ||
<template slot="title" scope="props"> | ||
{{props.title}}<i class="header-icon el-icon-information"></i> | ||
</template> | ||
<div>与现实生活一致:与现实生活的流程、逻辑保持一致,遵循用户习惯的语言和概念;</div> | ||
<div>在界面中一致:所有的元素和结构需保持一致,比如:设计样式、图标和文本、元素的位置等。</div> | ||
</el-collapse-item> | ||
<el-collapse-item title="Feedback"> | ||
<div>控制反馈:通过界面样式和交互动效让用户可以清晰的感知自己的操作;</div> | ||
<div>页面反馈:操作后,通过页面元素的变化清晰地展现当前状态。</div> | ||
</el-collapse-item> | ||
<el-collapse-item title="Efficiency"> | ||
<div>简化流程:设计简洁直观的操作流程;</div> | ||
<div>清晰明确:语言表达清晰且表意明确,让用户快速理解进而作出决策;</div> | ||
<div>帮助用户识别:界面简单直白,让用户快速识别而非回忆,减少用户记忆负担。</div> | ||
</el-collapse-item> | ||
<el-collapse-item title="Controllability"> | ||
<div>用户决策:根据场景可给予用户操作建议或安全提示,但不能代替用户进行决策;</div> | ||
<div>结果可控:用户可以自由的进行操作,包括撤销、回退和终止当前操作等。</div> | ||
</el-collapse-item> | ||
</el-collapse> | ||
``` | ||
::: | ||
|
||
### Collapse Attributes | ||
| 参数 | 说明 | 类型 | 可选值 | 默认值 | | ||
|---------- |-------------- |---------- |-------------------------------- |-------- | | ||
| accordion | 是否手风琴模式 | boolean | — | false | | ||
| value | 当前激活的面板(如果是手风琴模式,绑定值类型需要为`string`,否则为`array`) | string/array | — | — | | ||
|
||
### Collapse Events | ||
| 事件名称 | 说明 | 回调参数 | | ||
|---------|---------|---------| | ||
| change | 当前激活面板改变时触发(如果是手风琴模式,参数 `activeNames` 类型为`string`,否则为`array`) | (activeNames: array\|string) | | ||
|
||
### Collapse Item Attributes | ||
| 参数 | 说明 | 类型 | 可选值 | 默认值 | | ||
|---------- |-------------- |---------- |-------------------------------- |-------- | | ||
| name | 唯一标志符 | string/number | — | — | | ||
| title | 面板标题 | string | — | — | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.