Existing Component
Yes
Component Name
el-link
Description
There's no way to combine el-link
with router-link
.
<router-link to="foo">
<el-link>foo</el-link>
<router-link>
It is <a><a>foo</a></a>
, not permitted.
<router-link tag="span" to="foo">
<el-link>foo</el-link>
<router-link>
Browser's status bar doesn't work.
7条答案
按热度按时间to94eoyn1#
got the same issue here, i've figured out how to specify the router tag as:
<router-link tag="el-link" type="primary" :to="{ name: 'routename', params: { id: item.id } }"> {{ Link }} </router-link>
but the primary style doesn't work properly, don't know why, maybe it's an issue. hope this helps
tzdcorbm2#
Here's my solutions:
use a normal el-link tag with a click event that pushes to the desired route :)
bttbmeg03#
I thought the
v-slot
API could solve this problem: https://router.vuejs.org/api/#v-slot-api-3-1-0The code looks like this:
But
el-link
does not emit the click event when there is anhref
prop.element/packages/link/src/main.vue
Lines 44 to 50 in bf534d9
| | handleClick(event) { |
| | if (!this.disabled) { |
| | if (!this.href) { |
| | this.$emit('click', event); |
| | } |
| | } |
| | } |
@iamkun
Why doesn't
el-link
emit the click event?fcg9iug34#
I'm just using "route" menu item attribute like this:
rsaldnfx5#
This seems to work
exdqitrt6#
Here's my solutions:
use a normal el-link tag with a click event that pushes to the desired route :)
the problem was done, thanks
ltskdhd17#
Here is my solution:
doing this you can completly wrap the el-link inside a router-link without render the router link but keeping its behavoir.
The magic thing here is the
custom
attribute who tell router-link to not render anything !