英文:
The <el-dropdown> is experiencing an issue and cannot be used
问题
When using Element-Plus, I noticed that when I import el-dropdown, it doesn't seem to be rendered as a functional dropdown menu. Here is the code snippet I am using for it:
<template>
<div>
<el-dropdown>
<span class="el-dropdown-link">
Menu<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>黄金糕</el-dropdown-item>
<el-dropdown-item>狮子头</el-dropdown-item>
<el-dropdown-item>螺蛳粉</el-dropdown-item>
<el-dropdown-item disabled>双皮奶</el-dropdown-item>
<el-dropdown-item divided>蚵仔煎</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</template>
And this is how it appears/rendered:
When I hover over it, it only shows a black border, and the el-menu-item cannot be found within 'Elements'. What could be causing this? I haven't noticed any CSS affecting it.
英文:
When I'm using Element-Plus, I noticed that when I import el-dropdown, it doesn't seem to be rendered as a functional dropdown menu.
Here is the code snippet I am using for it.
<template>
<div>
<el-dropdown>
<span class="el-dropdown-link">
Menu<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>黄金糕</el-dropdown-item>
<el-dropdown-item>狮子头</el-dropdown-item>
<el-dropdown-item>螺蛳粉</el-dropdown-item>
<el-dropdown-item disabled>双皮奶</el-dropdown-item>
<el-dropdown-item divided>蚵仔煎</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</template>
And this is how it appears/rendered.
When I hover over it, it only shows a black border, and the el-menu-item cannot be found within 'Elements'. What could be causing this? I haven't noticed any CSS affecting it.
答案1
得分: 0
您正在使用不正确的 slot 语法
<el-dropdown-menu slot="dropdown">
...
</el-dropdown-menu>
根据 Element Plus 文档 ,应该是:
<template v-slot:dropdown>
<el-dropdown-menu>
...
</el-dropdown-menu>
</template>
或者使用简写方式:
<template #dropdown>
<el-dropdown-menu>
...
</el-dropdown-menu>
</template>
英文:
You're using incorrect slot syntax
<el-dropdown-menu slot="dropdown">
...
</el-dropdown-menu>
Following the Element Plus documentation it should be:
<template v-slot:dropdown>
<el-dropdown-menu>
...
</el-dropdown-menu>
</template>
Or using shorthand:
<template #dropdown>
<el-dropdown-menu>
...
</el-dropdown-menu>
</template>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论