-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 修复vue.use自动注册组件时没有兼容到不传prefix的场景 && 补充affix组件的demo和测试用例
- Loading branch information
Showing
11 changed files
with
181 additions
and
12 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,37 @@ | ||
--- | ||
order: 0 | ||
title: | ||
zh-CN: 基本 | ||
en-US: Type | ||
--- | ||
|
||
## zh-CN | ||
基本使用方式,默认会固定在浏览器窗口最上方,当元素固定时会加上vue-affix这个class,可以依据此class写固定状态的自定义样式 | ||
|
||
|
||
## en-US | ||
|
||
|
||
````jsx | ||
<v-affix> | ||
<v-button>affix</v-button> | ||
</v-affix> | ||
```` | ||
|
||
````vue-script | ||
new Vue({ | ||
el: 'body', | ||
components: { | ||
vButton: atui.Button, | ||
vAffix: atui.Affix | ||
}, | ||
data() { | ||
return { | ||
} | ||
}, | ||
methods: { | ||
} | ||
}) | ||
```` |
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,36 @@ | ||
--- | ||
order: 2 | ||
title: | ||
zh-CN: 偏移量 | ||
en-US: Type | ||
--- | ||
|
||
## zh-CN | ||
可以设置offset属性来设置距离窗口顶部达到指定偏移量后触发 ,默认为0 | ||
|
||
## en-US | ||
|
||
|
||
````jsx | ||
<v-affix :offset="100"> | ||
<v-button>100px to top</v-button> | ||
</v-affix> | ||
```` | ||
|
||
````vue-script | ||
new Vue({ | ||
el: 'body', | ||
components: { | ||
vButton: atui.Button, | ||
vAffix: atui.Affix | ||
}, | ||
data() { | ||
return { | ||
} | ||
}, | ||
methods: { | ||
} | ||
}) | ||
```` |
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,42 @@ | ||
--- | ||
order: 1 | ||
title: | ||
zh-CN: 滚动容器 | ||
en-US: Container to scroll | ||
--- | ||
|
||
## zh-CN | ||
用 `target` 设置 `Affix` 需要监听其滚动事件的元素,默认为 `window`。 | ||
|
||
## en-US | ||
Set a `target` for 'Affix', which is listen to scroll event of target element (default is `window`). | ||
|
||
````jsx | ||
<div id="affixTarget" style="width: 100%; height: 100px; background: #ccc; overflow-y: scroll; padding: 30px;"> | ||
<div style="height: 300px;"> | ||
<v-affix :target="getTarget"> | ||
<v-button>affix</v-button> | ||
</v-affix> | ||
</div> | ||
</div> | ||
```` | ||
|
||
````vue-script | ||
new Vue({ | ||
el: 'body', | ||
components: { | ||
vButton: atui.Button, | ||
vAffix: atui.Affix | ||
}, | ||
data() { | ||
return { | ||
} | ||
}, | ||
methods: { | ||
getTarget () { | ||
return document.getElementById('affixTarget') | ||
} | ||
} | ||
}) | ||
```` |
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,26 @@ | ||
--- | ||
category: Components | ||
type: Basic | ||
title: Affix | ||
subtitle: 固钉 | ||
--- | ||
|
||
将页面元素钉在可视范围。 | ||
|
||
## 何时使用 | ||
当内容区域比较长,需要滚动页面时,这部分内容对应的操作或者导航需要在滚动范围内始终展现。常用于侧边菜单和按钮组合。 | ||
|
||
页面可视范围过小时,慎用此功能以免遮挡页面内容。 | ||
|
||
|
||
## API | ||
|
||
|
||
### Button | ||
|
||
属性 | 说明 | 类型 | 默认值 | ||
-----|-----|-----|------ | ||
offset | 距离窗口顶部达到指定偏移量后触发 | `number` | 0 | | ||
target | 设置 `Affix` 需要监听其滚动事件的元素,值为一个返回对应 `DOM` 元素的函数 | `Function` | () => window | | ||
change | 固定状态改变时触发的回调函数 | `Function(affixed)` | | | ||
|
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,21 @@ | ||
import Vue from 'vue' | ||
import Button from '../../Button' | ||
import Affix from '../' | ||
|
||
let vm = new Vue({ | ||
template: ` | ||
<v-affix> | ||
<v-button>affix</v-button> | ||
</v-affix> | ||
`, | ||
components: { vButton: Button, vAffix: Affix }, | ||
data: { | ||
|
||
} | ||
}).$mount() | ||
|
||
describe('Affix', () => { | ||
it('Affix组件是否正常显示', () => { | ||
expect(vm.$el.querySelectorAll('div.atui-affix').length).to.equal(1) | ||
}) | ||
}) |
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