04 2021 档案
摘要:非父子组件之间的通信: 1.兄弟组件 2. 用了插槽slot的组件之间通信 vue2中可以使用eventBus事件监听 vm.$on('test', function (msg) { console.log(msg) }) vm.$emit('test', 'hi') vue3中,可以使用第三方插件
阅读全文
摘要:Attribute 继承 当组件返回单个根节点时,非 prop attribute 将自动添加到根节点的 attribute 中。 同样的规则适用于事件监听器 禁用 Attribute 继承 如果你不希望组件的根元素继承 attribute,你可以在组件的选项中设置 inheritAttrs: fa
阅读全文
摘要:按照vue3的组件v-model初探1,把:value 用 v-model来替代,并使用computed计算属性 子组件: <template> <div> <input v-model="val"> <div>{{ modelValue }} {{ val }}</div> </div> </te
阅读全文
摘要:父组件: <template> <div class="about"> <v-input v-model="inp" type="text" /> </div> </template> <script lang="ts"> import { defineComponent, ref } from '
阅读全文