问题答案 12026年5月29日 02:29
Vue - router : How to remove underline from router - link
In Vue.js projects using Vue Router, by default, the links generated by the component may display underlines because browsers typically apply underline styles to tags. To remove these underlines from , you can use CSS.Method 1: Modify in Global StylesYou can add rules in the global CSS file to remove underlines from all tags generated by :This approach affects all tags in the project, so if you want to target only , use more specific selectors.Method 2: Use Specific SelectorsIf you want to modify only the styles for , you can add a specific class or use existing classes to define the styles:Here, and are classes added by Vue Router for active route links, and you can use them to remove underlines from active links.Method 3: Use Inline Styles in ComponentsIf you prefer not to modify styles in CSS files, you can directly apply inline styles to the component:This directly applies styles to the link to remove underlines.ExampleThe following is a simple Vue component example demonstrating how to remove underlines from using CSS classes:In this example, the class is applied to all components, thereby removing the underlines. This approach keeps your code clear and organized while avoiding the effects of global styles.These methods can be chosen and adjusted based on the specific needs of your project and the existing style architecture.