pas*_*ner 3 css vue.js vue-router vuejs2 routerlink
我想我尝试了几乎所有尝试从router-link.
这是我的代码:
<router-link :to="{name: 'Plan'}">
<div>Plan Your Trip</div>
<div class='expander'>
<router-link :to="{name: 'Plan'}">COVID-19</router-link>
<router-link :to="{name: 'Plan'}">Visa</router-link>
<router-link :to="{name: 'Plan'}">Essentials</router-link>
</div>
</router-link>
Run Code Online (Sandbox Code Playgroud)
我正在尝试仅从子链接中删除下划线。
我尝试过的事情:
内嵌样式
<router-link style="text-decoration: none !important;" :to="{name: 'Plan'}">COVID-19</router-link>
Run Code Online (Sandbox Code Playgroud)
分配班级
<router-link class="sub-link" :to="{name: 'Plan'}">COVID-19</router-link>
<style scoped>
.sub-link{text-decoration: none !important;}
</style>
Run Code Online (Sandbox Code Playgroud)
声明标签
<router-link tag="div" :to="{name: 'Plan'}">COVID-19</router-link>
<style scoped>
div{text-decoration: none !important;}
</style>
Run Code Online (Sandbox Code Playgroud)
为该标签分配单独的标签+声明类
<router-link :to="{name: 'Plan'}">
<div class="sub-link">COVID-19</div>
</router-link>
Run Code Online (Sandbox Code Playgroud)
这些只是几个列表,我确实尝试了我能想到的所有可能的方法......我是否遗漏了自定义 Vue 的一些内容router-link?
使用display: inline-block;text-decoration:none;,诀窍是display: inline-block; .
CSS 规范状态
对于建立内联格式化上下文的块容器,装饰将传播到一个匿名内联元素,该元素包装块容器的所有内联内联级子项。对于所有其他元素,它会传播到任何流入的子元素。请注意,文本修饰不会传播到浮动和绝对定位的后代,也不会传播到原子内联级后代(例如内联块和内联表)的内容。
示例:COVID-19代码中的链接将删除下划线。
<router-link :to="{name: 'Plan'}">
<div>Plan Your Trip</div>
<div class='expander'>
<router-link :to="{name: 'Plan'}" style="display: inline-block;text-decoration:none;">COVID-19</router-link>
<router-link :to="{name: 'Plan'}">Visa</router-link>
<router-link :to="{name: 'Plan'}">Essentials</router-link>
</div>
</router-link>
Run Code Online (Sandbox Code Playgroud)
下面是一个演示:
<router-link :to="{name: 'Plan'}">
<div>Plan Your Trip</div>
<div class='expander'>
<router-link :to="{name: 'Plan'}" style="display: inline-block;text-decoration:none;">COVID-19</router-link>
<router-link :to="{name: 'Plan'}">Visa</router-link>
<router-link :to="{name: 'Plan'}">Essentials</router-link>
</div>
</router-link>
Run Code Online (Sandbox Code Playgroud)
let Layout = {
template: `<div>
<h4>Layout Page </h4>
<router-link to="/contact">
<div>
<p>Links<p>
<router-link to="/contact/add" style="display: inline-block;text-decoration:none;">Add1</router-link>
<router-link to="/addcontact">Add2</router-link>
</div>
</router-link>
<router-view></router-view>
</div>`
};
let Home = {
template: '<div>this is the home page. Go to <router-link to="/contact">contact</router-link> </div>'
};
let ContactList = {
// add <router-view> in order to load children route of path='/contact'
template: '<div>this is contact list, click <router-link to="/contact/add">Add Contact In sub Router-View</router-link> here to add contact<p><router-view></router-view></p> Or Click <router-link to="/addcontact">Add Contact In Current Router-View</router-link></div>'
};
let ContactAdd = {
template: '<div>Contact Add</div>'
}
let router = new VueRouter({
routes: [{
path: '/',
redirect: 'home',
component: Layout,
children: [{
path: 'home',
component: Home
},
{
path: 'contact',
component: ContactList,
children: [{
path: 'add',
component: ContactAdd
}]
},
{
path: 'addcontact', // or move ContactAdd as direct child route of path=`/`
component: ContactAdd,
}
]
}]
});
new Vue({
el: '#app',
components: {
'App': {
template: '<div><router-view></router-view></div>'
},
},
router
});Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
905 次 |
| 最近记录: |