如何在局域网建立网站,广告公司网站设计方案,h1z1注册网站,辽宁建设工程信息网官网为什么打不开//透传简单来说就是在子组件写style,class或者函数可以将它们#xff0c;自动直接传递给 template#xff1a;里面的单个节点。
//多个节点透传的自动传递会生效#xff0c;如果在节点中像使用#xff0c;那么就需要在对应的节点中写像:style$attrs.style的形…//透传简单来说就是在子组件写style,class或者函数可以将它们自动直接传递给 template里面的单个节点。
//多个节点透传的自动传递会生效如果在节点中像使用那么就需要在对应的节点中写像:style$attrs.style的形式才能对应的样式或函数接收到
//inheritAttrs: false可以阻止透传
!DOCTYPE html html langen head meta charsetUTF-8 meta nameviewport contentwidthdevice-width, initial-scale1.0 titleDocument/title /head body div idapp divApp 父组件/div hr son classbox stylewidth: 300px; height: 200px; background: #ccc; clickhandleClick /son /div script src./lib/vue.global.js/script script const app Vue.createApp({ methods: { handleClick() { console.log(点击了子组件) }, } }) app.component(son, { template: div classcontainer stylebackground: #f00; clickhandleSonClick 这是子组件 /div div :style$attrs.style第二个节点/div , methods: { handleSonClick() { console.log(这是子组件的 son click 事件...) }, }, }) app.mount(#app) /script /body /html