我希望在我的 Web 應用程式中包含一個效果,強調我們在部分串列中的部分。我正在與 Nuxt 合作。
我不知道為什么下面的代碼不會改變 boolean 的值isActive。
<nuxt-link
:to="`${path}/${filterItem.filter}`"
:style='{"text-decoration": (isActive ? "underline" : "none")}'
@click="selectSeason(filterItem.filter) toggleUnderline()" >
methods: {
selectSeason(filter) {
this.$router.push(`${this.path}/${filter}`)
},
toggleUnderline() {
this.isActive = !this.isActive
}
},
uj5u.com熱心網友回復:
你可能可以用這樣的東西來實作這一點
<template>
<nuxt-link to="/about" :custom="true">
<a @click="test">go to about page</a>
</nuxt-link>
</template>
<script>
export default {
methods: {
test() {
console.log('called test method')
},
},
}
</script>
如此處所示:https ://github.com/vuejs/router/issues/846#issuecomment-808150258
甚至認為,這可能不是總體上最好的方法,而且對于一個簡單的用例來說似乎太hacky了。
如果您想要一個操作,請使用button標簽,否則將條件邏輯放在您的路線上,但不要混合客戶端導航和某種點擊事件。
uj5u.com熱心網友回復:
在 Nuxt3中,如果它處于活動狀態,<NuxtLink>則會得到一個,因此您可以使用它們來為活動鏈接添加下劃線。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/496262.html
上一篇:物件可能未定義
下一篇:DataFrame中的數字格式
