<template>
<a class="nav-link" :class="activeClasses" :href="page.link.url">
{{ page.link.text }}
</a>
</template>
<script>
export default {
props: ["page", "isActive"],
computed: {
activeClasses() {
return {
active: this.isActive,
emphasize: this.isActive,
};
},
},
};
</script>
<style scoped>
.emphasize {
text-decoration: underline !important;
}
</style>
我尝试在导航栏文本上加下划线,但不起作用。
2条答案
按热度按时间bjp0bcyl1#
您的组件按预期工作。似乎你传递了错误的props给你的组件。在这里它工作得很好:
Vue.js Playground
hc2pp10m2#
我同意 Alexandria 。你可能想像这样修改你的 prop :