<el-dropdown>正在遇到问题,无法使用

huangapple go评论55阅读模式
英文:

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:

enter image description here

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.

&lt;template&gt;
  &lt;div&gt;
    &lt;el-dropdown&gt;
    &lt;span class=&quot;el-dropdown-link&quot;&gt;
      Menu&lt;i class=&quot;el-icon-arrow-down el-icon--right&quot;&gt;&lt;/i&gt;
    &lt;/span&gt;
    &lt;el-dropdown-menu slot=&quot;dropdown&quot;&gt;
      &lt;el-dropdown-item&gt;黄金糕&lt;/el-dropdown-item&gt;
      &lt;el-dropdown-item&gt;狮子头&lt;/el-dropdown-item&gt;
      &lt;el-dropdown-item&gt;螺蛳粉&lt;/el-dropdown-item&gt;
      &lt;el-dropdown-item disabled&gt;双皮奶&lt;/el-dropdown-item&gt;
      &lt;el-dropdown-item divided&gt;蚵仔煎&lt;/el-dropdown-item&gt;
    &lt;/el-dropdown-menu&gt;
  &lt;/el-dropdown&gt;
  &lt;/div&gt;
&lt;/template&gt;

And this is how it appears/rendered.

enter image description here

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 语法

&lt;el-dropdown-menu slot=&quot;dropdown&quot;&gt;
 ...
&lt;/el-dropdown-menu&gt;

根据 Element Plus 文档 ,应该是:

&lt;template v-slot:dropdown&gt;
  &lt;el-dropdown-menu&gt;
  ...
  &lt;/el-dropdown-menu&gt;
&lt;/template&gt;

或者使用简写方式:

&lt;template #dropdown&gt;
  &lt;el-dropdown-menu&gt;
  ...
  &lt;/el-dropdown-menu&gt;
&lt;/template&gt;

codepen 示例

英文:

You're using incorrect slot syntax

&lt;el-dropdown-menu slot=&quot;dropdown&quot;&gt;
 ...
&lt;/el-dropdown-menu&gt;

Following the Element Plus documentation it should be:

&lt;template v-slot:dropdown&gt;
  &lt;el-dropdown-menu&gt;
  ...
  &lt;/el-dropdown-menu&gt;
&lt;/template&gt;

Or using shorthand:

&lt;template #dropdown&gt;
  &lt;el-dropdown-menu&gt;
  ...
  &lt;/el-dropdown-menu&gt;
&lt;/template&gt;

codepen example

huangapple
  • 本文由 发表于 2023年6月6日 01:02:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76408574.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定