[Vue Pattern] Transparent Component Pattern

<template>
    <div>
        <input type="text" v-bind="$attrs" />
    </div>
</template>

<script setup lang="ts" >
// by default when you pass props to the component, Vue will attach those props to the root of the component
// in this case, is the <div>, by using `inheritAttrs: false`, Vue will attach props to the place we write $attrs
defineOptions({
  inheritAttrs: false
})
</script>
    

 

See more: https://vuejs.org/guide/components/attrs#disabling-attribute-inheritance

 

posted @   Zhentiw  阅读(2)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
历史上的今天:
2024-03-04 [Rust] ref keyword for borrow value
2024-03-04 [Rust] if let & while let
2024-03-04 [Rust] Using .map_err instead of wrap which cause panic
2024-03-04 [Rust] Using Box<dyn error::Error>> return one of miultiple error types at runtime
2022-03-04 [AWS Explained] Security
2020-03-04 [AST Babel] Babel Template
2020-03-04 [HTML5] Layout Reflow & thrashing
点击右上角即可分享
微信分享提示