随笔分类 -  Vue

摘要:vue中如果父组件想调用子组件的方法,可以在子组件中加上ref,然后通过this.$refs.ref.method调用,例如: 父组件: <template> <div @click="fatherMethod"> <child ref="child"></child> </div> </templ 阅读全文
posted @ 2020-03-28 08:19 kitterKing 阅读(305) 评论(0) 推荐(0)
摘要:第一种方法是直接在子组件中通过this.$parent.event来调用父组件的方法 父组件 <template> <div> <child></child> </div> </template> <script> import child from '~/components/dam/child' 阅读全文
posted @ 2020-03-28 08:18 kitterKing 阅读(12332) 评论(0) 推荐(1)
摘要:listenPage() { window.onbeforeunload = function (e) { e = e || window.event; if (e) { e.returnValue = '关闭提示'; } return '关闭提示'; }; } 在mounted中调用即可,当按下F 阅读全文
posted @ 2020-03-27 16:42 kitterKing 阅读(13775) 评论(0) 推荐(1)
摘要:一、父组件调用子组件函数 父组件: <template> <child ref="editFun"></child> //子组件绑定 </template> 父组件调用子组件函数 this.$refs.editFun.init(参数); 子组件: methods:{ init(参数){ //父组件调 阅读全文
posted @ 2020-03-27 16:24 kitterKing 阅读(575) 评论(0) 推荐(0)
摘要:在vue.config.js中设置 devServer: { port: 1888, proxy: { '/api': { //本地服务接口地址 target: 'http://localhost', //远程演示服务地址,可用于直接启动项目 //target: 'https://saber.bla 阅读全文
posted @ 2020-03-20 15:10 kitterKing 阅读(1863) 评论(0) 推荐(0)