[Vue warn]: Extraneous non-props attributes (class)

// 最外层多个标签,无法在使用子组件标签上定义 class

// 会报错:Vue warn: Extraneous non-props attributes (class)

// were passed to component but could not be automatically inherited

// because component renders fragment or text root nodes.

// at <Demo3 class="green" > at <App>

// 下面把这个问题解决了:绑定父标签的属性值

app.component('demo3', {

template: `

<div :class="$attrs.class">zibo31</div>

<div :class="$attrs.class">zibo32</div>

`

});

相关推荐
不好听6138 分钟前
JavaScript Promise 从入门到精通(一):为什么需要 Promise 以及它是什么
javascript
西柚小萌新11 分钟前
【论文写作】--LaTeX详细入门教程2
前端·html
qdkfz11 分钟前
JavaScript 如何解析 Outlook .msg 文件 —— @kenjiuno/msgreader
前端·javascript
李明卫杭州14 分钟前
Vue3 Suspense 组件详解:从入门到避坑指南
vue.js
LuckyDog阿祥31 分钟前
卸载Microsoft Edge:EdgeRemover完整操作指南
前端·edge
zhangxingchao35 分钟前
AI应用开发九:从 Hermes Agent 学长期记忆
前端·人工智能·后端
xiaofeichaichai1 小时前
Vite原理与Webpack对比
前端·webpack·node.js
_杨瀚博1 小时前
小程序拍证件并局部裁剪
前端
张元清1 小时前
React useReducedMotion Hook:尊重 prefers-reduced-motion(2026)
javascript·react.js