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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { findComponentUpward } from '../../utils/assist';
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AnchorLink',
|
name: 'AnchorLink',
|
||||||
|
inject: ['anchorCom'],
|
||||||
props: {
|
props: {
|
||||||
href: String,
|
href: String,
|
||||||
title: String
|
title: String
|
||||||
|
@ -21,29 +21,23 @@ export default {
|
||||||
anchorLinkClasses () {
|
anchorLinkClasses () {
|
||||||
return [
|
return [
|
||||||
this.prefix,
|
this.prefix,
|
||||||
this.currentLink === this.href ? `${this.prefix}-active` : ''
|
this.anchorCom.currentLink === this.href ? `${this.prefix}-active` : ''
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
linkTitleClasses () {
|
linkTitleClasses () {
|
||||||
return [
|
return [
|
||||||
`${this.prefix}-title`
|
`${this.prefix}-title`
|
||||||
];
|
];
|
||||||
},
|
|
||||||
parentAnchor () {
|
|
||||||
return findComponentUpward(this, 'Anchor');
|
|
||||||
},
|
|
||||||
currentLink () {
|
|
||||||
return this.parentAnchor.currentLink;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
goAnchor () {
|
goAnchor () {
|
||||||
this.parentAnchor.turnTo(this.href);
|
this.anchorCom.turnTo(this.href);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.parentAnchor.init();
|
this.anchorCom.init();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,6 +15,11 @@ import { scrollTop, findComponentDownward, findComponentsDownward, sharpMatcherR
|
||||||
import { on, off } from '../../utils/dom';
|
import { on, off } from '../../utils/dom';
|
||||||
export default {
|
export default {
|
||||||
name: 'Anchor',
|
name: 'Anchor',
|
||||||
|
provide () {
|
||||||
|
return {
|
||||||
|
anchorCom: this
|
||||||
|
};
|
||||||
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
prefix: 'ivu-anchor',
|
prefix: 'ivu-anchor',
|
||||||
|
|
Loading…
Add table
Reference in a new issue