2019建设什么网站好运营,深圳英文网站建站,无锡,珠海新盈科技网站建设一般用于组件封装#xff0c;将使用props传入组件的数据再次调出来或者单纯调用组件中的数据。也可用于为组件某个部分自定义样式以及为某次使用组件自定义样式。 直接拿elementui的el-table举例#xff1a;
templateel-table v-loadingloading将使用props传入组件的数据再次调出来或者单纯调用组件中的数据。也可用于为组件某个部分自定义样式以及为某次使用组件自定义样式。 直接拿elementui的el-table举例
templateel-table v-loadingloading :dataform selection-changehandleSelectionChange idoutTable v-showfalseel-table-column label日期 aligncenter propxmccbgrq width180template slot-scopescopespan{{}}/span/template/el-table-columnel-table-column label项目状态 aligncenter propxmzt :formatterxmztFormat //el-table
/templatescript
export default {data(){return{isOpen:[{name:关,data:0 },{name:关,data:1 }].form:[]}}
}
/script可以看到子组件中使用了template标签还能拿到参数。 自己封装方法如下用的vue3vue2的话v-slot:default改成slot-scope然后3和2语法换一换就行了 子组件
script setup langts
import HelloWorld from ./components/HelloWorld.vue
/scripttemplatediva hrefhttps://vitejs.dev target_blankimg src/vite.svg classlogo altVite logo //aa hrefhttps://vuejs.org/ target_blankimg src./assets/vue.svg classlogo vue altVue logo //a/divHelloWorld msg我是传递的值template v-slot:defaultscopediv stylefont-size: 50px;color: pink{{scope.rows}}/div/template/HelloWorld
/templatestyle scoped
.logo {height: 6em;padding: 1.5em;will-change: filter;transition: filter 300ms;
}
.logo:hover {filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.vue:hover {filter: drop-shadow(0 0 2em #42b883aa);
}
/style父组件
script setup langts
import { ref } from vuedefineProps{ msg: string }()const count ref(0)
/scripttemplateh1{{ msg }}/h1div classcardbutton typebutton clickcountcount is {{ count }}/buttonpEditcodecomponents/HelloWorld.vue/code to test HMRslot :rowsmsg/slot/p/divpCheck outa hrefhttps://vuejs.org/guide/quick-start.html#local target_blankcreate-vue/a, the official Vue Vite starter/ppInstalla hrefhttps://github.com/vuejs/language-tools target_blankVolar/ain your IDE for a better DX/pp classread-the-docsClick on the Vite and Vue logos to learn more/p
/templatestyle scoped
.read-the-docs {color: #888;
}
/style效果 这里只是基础用法具体封装传递参数还要根据需求来。