摘要: ##一、安装axios插件 npm install axios --save //或者 yarn add axios //或者 cnpm install axios --save 注:安装包的时候 后面的 --save,如果不加,只安装在当前项目,把代码发给别人,是运行不了的,所以安装工具类包等,尽 阅读全文
posted @ 2021-04-05 15:59 清和时光 阅读(9623) 评论(0) 推荐(0) 编辑
摘要: slots (插槽),父组件在使用子组件的时候,在子组件插入任意内,包括html 举个小例子: 1、自定义一个按钮组件 <template> <div> <button class="btn-primary"> <slot>default</slot> </button> </div> </temp 阅读全文
posted @ 2021-04-05 14:31 清和时光 阅读(2651) 评论(0) 推荐(0) 编辑
摘要: ###Vue 3.x中非父子组件是需要通过一个第三方插件mitt来完成的 一、首先安装插件 mitt npm install --save mitt 二、创建文件 model/event.js import mitt from 'mitt' const VueEvent=mitt(); export 阅读全文
posted @ 2021-04-05 11:58 清和时光 阅读(984) 评论(0) 推荐(1) 编辑
摘要: ###组件有各种事件,比如,点击事件 @click 、键盘事件 @keyup v-on: 指令可以简写成 @ ##一、自定义组件中,子组件获取父组件的数据 1、调用子组件时,定义事件<my-header @parentRun="run"></my-header> <template> <div> / 阅读全文
posted @ 2021-04-05 11:28 清和时光 阅读(5803) 评论(0) 推荐(1) 编辑
摘要: ##一、父组件给子组件传值 ###1、父组件调用子组件时,在子组件上加上绑定参数 <template> <div> <!-- 3、展示组件,:title="msg" 表示向<my-header> 子组件传入参数title ,也可以使用 home="this" 把整个父组件传给子组件><--> <my 阅读全文
posted @ 2021-04-05 09:33 清和时光 阅读(7264) 评论(0) 推荐(0) 编辑