
vue
Frankiness
这个作者很懒,什么都没留下…
展开
-
使用extend封装一个全局弹窗组件
概念 extend是一个组件构造器,传入包含组件选项的对象,返回一个Vue的子类,也就是组件 步骤 1.弹窗组件toast.vue <template> <div> <div class="container" v-if="show"> <span>{{ text }}</span> </div> </div> </template> <script> export原创 2021-04-09 11:55:41 · 246 阅读 · 0 评论 -
Vue子父组件间的传值
父传子值 1、子组件使用v-bind绑定父组件中的数据 <child :child="parent"></child> 2、在子组件中使用props创建自定义的接收数据属性 props['child'] 3、就可以在子组件模版中使用数据了 子传父值 1、将需要传的值作为$emit的第二个参数,该值将作为实参传给响应自定义事件的方法 msg(){ this.$emit('target',data) } 2、在父组件中先定义一个接受子组件数据的函数,data是子组件传递过来原创 2020-07-10 17:24:02 · 135 阅读 · 0 评论