update Anchor

This commit is contained in:
梁灏 2018-06-29 15:42:24 +08:00
parent 2b98434e90
commit c69f8ff5fb
2 changed files with 9 additions and 10 deletions

View file

@ -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();
});
}
};

View file

@ -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',