vue---父调子 $refs (把父组件的数据传给子组件)
2024-08-27 07:10:25
ps:App.vue 父组件
Hello.vue 子组件
App.vue :
<template>
<div id="app">
<input type="button" name="" id="" @click="parentCall" value="父调子" />
<hello ref="chil" />//hello组件
</div>
</template> <script>
import hello from './components/Hello'
export default {
name: 'app',
'components': {
hello
},
methods: {
parentCall () {
this.$refs.chil.chilFn('我是父元素传过来的')
}
}
}
</script> /*Hello.vue :*/ <template>
<div class="hello"></div>
</template> <script>
export default {
name: 'hello',
'methods': {
chilFn (msg) {
alert(msg)
}
}
}
</script>
最新文章
- shell 1>;&;2 2>;&;1 &;>;filename重定向的含义和区别
- System.Web.AspNetHostingPermission 类型的权限已失败
- android插件中或者library中获取asstes文件
- [HB2014 Week5] Allot 人员分配
- 收集的maven 仓库地址(maven repository)
- Javascript 固定表格表头
- IE11打不开网页, 所有菜单都被禁用了。
- INTERPRETER(解释器)
- 【BZOJ】1006: [HNOI2008]神奇的国度 弦图消除完美序列问题
- C#小数点位数处理方法
- .net core 使用Redis的发布订阅
- 交互题[CF1103B Game with modulo、CF1019B The hat、CF896B Ithea Plays With Chtholly]
- Java oop(一些自己的理解,并没有展开很细)
- Incorrect username or password ( access token )解决
- H5页面分享微信自定义分享title和img
- 4. easyui删除功能实例
- oracle 锁表查看与解锁
- [转]Redis几个认识误区
- eclipse lua
- MVC ViewData与ViewBag的区别