1# 事件参数<a name="ZH-CN_TOPIC_0000001164130780"></a> 2 3子组件也可以通过绑定的事件向上传递参数,在自定义事件上添加传递参数的示例如下: 4 5``` 6<!-- comp.hml --> 7<div class="item"> 8 <text class="text-style" onclick="childClicked">点击这里查看隐藏文本</text> 9 <text class="text-style" if="{{showObj}}">hello world</text> 10</div> 11``` 12 13``` 14// comp.js 15export default { 16 childClicked () { 17 this.$emit('eventType1', {text: '收到子组件参数'}); 18 this.showObj = !this.showObj; 19 }, 20} 21``` 22 23子组件向上传递参数text,父组件接收时通过e.detail来获取参数: 24 25``` 26<!-- xxx.hml --> 27<div class="container"> 28 <text>父组件:{{text}}</text> 29 <comp @event-type1="textClicked"></comp> 30</div> 31``` 32 33``` 34// xxx.js 35export default { 36 data: { 37 text: '开始', 38 }, 39 textClicked (e) { 40 this.text = e.detail.text; 41 }, 42} 43``` 44 45