update Anchor
This commit is contained in:
parent
2b98434e90
commit
c69f8ff5fb
2 changed files with 9 additions and 10 deletions
|
@ -5,9 +5,9 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { findComponentUpward } from '../../utils/assist';
|
||||
export default {
|
||||
name: 'AnchorLink',
|
||||
inject: ['anchorCom'],
|
||||
props: {
|
||||
href: String,
|
||||
title: String
|
||||
|
@ -21,29 +21,23 @@ export default {
|
|||
anchorLinkClasses () {
|
||||
return [
|
||||
this.prefix,
|
||||
this.currentLink === this.href ? `${this.prefix}-active` : ''
|
||||
this.anchorCom.currentLink === this.href ? `${this.prefix}-active` : ''
|
||||
];
|
||||
},
|
||||
linkTitleClasses () {
|
||||
return [
|
||||
`${this.prefix}-title`
|
||||
];
|
||||
},
|
||||
parentAnchor () {
|
||||
return findComponentUpward(this, 'Anchor');
|
||||
},
|
||||
currentLink () {
|
||||
return this.parentAnchor.currentLink;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
goAnchor () {
|
||||
this.parentAnchor.turnTo(this.href);
|
||||
this.anchorCom.turnTo(this.href);
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.$nextTick(() => {
|
||||
this.parentAnchor.init();
|
||||
this.anchorCom.init();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -15,6 +15,11 @@ import { scrollTop, findComponentDownward, findComponentsDownward, sharpMatcherR
|
|||
import { on, off } from '../../utils/dom';
|
||||
export default {
|
||||
name: 'Anchor',
|
||||
provide () {
|
||||
return {
|
||||
anchorCom: this
|
||||
};
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
prefix: 'ivu-anchor',
|
||||
|
|
Loading…
Add table
Reference in a new issue