上一页 1 ··· 5 6 7 8 9 10 下一页
摘要: 在src下新建一个文件夹和文件js 然后在js文件里写入 import axios from 'axios' //引入下载的axios const instance = axios.create({ baseURL:'接口地址', timeout:5000 //几秒 })//创建实例 instanc 阅读全文
posted @ 2021-04-13 17:40 light丶 阅读(1772) 评论(0) 推荐(0)
摘要: beforeCreate(){ console.log('实例刚刚被创建') }, created(){ console.log('实例已经创建完成') }, beforeMount(){ console.log('模板编译之前'); }, mounted(){ console.log('数据更新之 阅读全文
posted @ 2021-04-12 11:03 light丶 阅读(851) 评论(0) 推荐(0)
摘要: 子组件 MyBar <template> <div> <slot name="two" :user1='usname'></slot>// 有名字的插槽 <slot :user='usname'></slot> //无名字插槽 :user 自己命名的属性,'usname'就是data里的值 //通过 阅读全文
posted @ 2021-04-09 17:35 light丶 阅读(6635) 评论(0) 推荐(0)
摘要: 一般不使用具名插槽时,都是这样使用 子组件 MyBar <template> <slot> <button>点我</button> //如果父组件在使用子组件的时没有写入标签或内容就会默认显示button </slot> </template> 父组件 MySideBar <template> <m 阅读全文
posted @ 2021-04-09 17:08 light丶 阅读(2673) 评论(0) 推荐(1)
摘要: 子组件 展示变量,把在data里把变量设为0 声明一个自定义方法,进行相操作的步骤 父组件 给一个button加一个点击事件 并在引入的子组件上给一个名字ref='名字' 在自定义事件里先声明事件 然后通过this.$refs方法找到刚才给子组件的名字访问其事件或变量 如 this.$refs.aa 阅读全文
posted @ 2021-04-08 17:04 light丶 阅读(1162) 评论(0) 推荐(0)
摘要: 首先要在父组件里引入子组件 父 在父组件里声明一个事件,并不进行操作 子 在子组件里声明一个点击事件 然后在方法里使用 $parent:是在子组件中可以直接访问该组件的父实例或组件 methods: { one(){ this.$parent.changen(); //操作父组件的方法 change 阅读全文
posted @ 2021-04-08 15:51 light丶 阅读(5535) 评论(1) 推荐(0)
摘要: 如图 当我们使用子组件的值传给父组件时要用到$emit 子组件 给子组件设置一个事件,括号里是传的值,如图 然后在自定义事件里使用和emit,如图 ,注$emit(‘事件名’,要传给父组件的值) 当我们点击子组件的(changcount)事件时很触发父类的(mycontevent)事件监听 父组件 阅读全文
posted @ 2021-04-08 11:48 light丶 阅读(5703) 评论(0) 推荐(0)
摘要: 在使用组件通信时我们先看一张图 看完后就知道使用父传子时要用到props,现在就开始使用在vue里创建一个父组件,和一个子组件 父组件传值 在父组件App.vue里先导入子组件 然后注册 然后再 template 直接使用 <template > <div> <MyMain> </MyMain> < 阅读全文
posted @ 2021-04-07 17:53 light丶 阅读(1790) 评论(0) 推荐(0)
摘要: HTML <view class="term"> <checkbox-group bindchange="checkboxChange"> <checkbox value="{{myVal}}" checked="{{is_agree}}"/> 我已阅读并<text class="fr1" bind 阅读全文
posted @ 2021-01-21 16:03 light丶 阅读(3589) 评论(0) 推荐(0)
摘要: 在pages同层目录下创建一个componets如图 在componets下创建一个文件夹 对dialog文件夹右键使用新建componet(注Component 构造器可用于定义组件) 在dialog.json文件里 component必须为ture, 以下是HTML <view class="d 阅读全文
posted @ 2021-01-21 14:59 light丶 阅读(1220) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 下一页