开发避坑短篇(9):解决升级Vue3后slot attributes废弃警告
报错信息
`slot` attributes are deprecated
异常分析
在Vue3中,使用slot和slot-scope属性来指定插槽内容已经被废弃。在Vue2中,这是定义插槽的主要方式。Vue3推荐使用标签和v-slot指令来代替这两个属性。
解决办法
Vue2中的写法
<span slot="footer" class="dialog-footer"><el-button type="primary" @click="submit" :loading="loading">提交</el-button><el-button type="primary" @click="save">保存</el-button><el-button @click="closeApply">取消</el-button>
</span>
Vue3中的写法
<template v-slot:footer><div class="dialog-footer"><el-button type="primary" @click="submit" :loading="loading">提交</el-button><el-button type="primary" @click="save">保存</el-button><el-button @click="closeApply">取消</el-button></div>
</template>