错误显示
<el-dropdown-menu>
<el-dropdown-item v-for="item in userOs" :key="item.id" :command="item.name" >
<span class="iconfont" >{{item.icon}}</span>{{item.title}}
</el-dropdown-item>
</el-dropdown-menu>

使用v-html解决


文章讲述了在Vue应用中遇到<el-dropdown-menu>组件内<el-dropdown-item>元素通过v-for遍历数据时出现的错误显示,提出使用v-html属性来正确地呈现item的title和icon。这种方法帮助开发者更好地控制dropdown菜单的内容渲染。
错误显示
<el-dropdown-menu>
<el-dropdown-item v-for="item in userOs" :key="item.id" :command="item.name" >
<span class="iconfont" >{{item.icon}}</span>{{item.title}}
</el-dropdown-item>
</el-dropdown-menu>

使用v-html解决



被折叠的 条评论
为什么被折叠?