当前位置: 首页 > news >正文

杭州网站优化方案合肥做个网站多少钱

杭州网站优化方案,合肥做个网站多少钱,做软件的中介网站,用ppt做网站方法需求中有个场景是需要在子组件中传多个参数&#xff0c;让父组件接收所有入参&#xff0c;并且父组件也要加自己的参数 1.子组件传多个参数给父组件 子组件 // 子组件 ChildComponent.vue <template><button click"sendDataToParent">传递数据给父组件…

需求中有个场景是需要在子组件中传多个参数,让父组件接收所有入参,并且父组件也要加自己的参数

1.子组件传多个参数给父组件

子组件

// 子组件 ChildComponent.vue
<template><button @click="sendDataToParent">传递数据给父组件</button>
</template><script>
export default {methods: {sendDataToParent() {const param1 = '参数1';const param2 = '参数2';this.$emit('send-data', param1, param2);}}
}
</script>

父组件

// 父组件 ParentComponent.vue
<template><div><ChildComponent @send-data="handleDataFromChild"></ChildComponent></div>
</template><script>
export default {methods: {handleDataFromChild(param1, param2) {console.log('参数1:', param1);console.log('参数2:', param2);}}
}
</script>

2.子组件传1个参数给父组件 ,并且父组件函数也传1个参数

子组件:

// 子组件 ChildComponent.vue
<template><button @click="sendDataToParent">传递数据给父组件</button>
</template><script>
export default {methods: {sendDataToParent() {const param1 = '参数1';this.$emit('send-data', param1);}}
}
</script>

 父组件:

// 父组件 ParentComponent.vue
<template><div><ChildComponent @send-data="handleDataFromChild($event,'customParam')"></ChildComponent></div>
</template><script>
export default {methods: {handleDataFromChild(param1, customParam) {console.log('参数1:', param1);console.log('自定义参数:', customParam);}}
}
</script>

 3.子组件传2个参数给父组件 ,并且父组件函数也传1个参数

子组件

// 子组件 ChildComponent.vue
<template><button @click="sendDataToParent">传递数据给父组件</button>
</template><script>
export default {methods: {sendDataToParent() {const param1 = '参数1';const param2 = '参数2';this.$emit('send-data', param1, param2);}}
}
</script>

父组件

 

// 父组件 ParentComponent.vue
<template><div><ChildComponent @send-data="handleDataFromChild(arguments,'customParam')"></ChildComponent></div>
</template><script>
export default {methods: {handleDataFromChild(chlidParams, customParam) {console.log('子组件中多个参数:', chlidParams);console.log('自定义参数:', customParam);}}
}
</script>

http://www.yayakq.cn/news/226827/

相关文章:

  • 网站建设的模板自己做网站制作教程
  • 大中型网站开发流程开发者模式开着好不好
  • 鄂州建设网站手机上怎么审营业执照
  • 聊城做网站最好的网络公司seo是指什么岗位
  • 国家建设工程网站wordpress支持广告播放器
  • 恒通建设集团有限公司网站绵阳公司网站制作公司
  • 12306网站 谁做的电商运营培训机构排名
  • 网站app简单做高清的网站建设
  • 网站无备案官方购物网站正品
  • 优秀的电商设计网站有哪些重庆网站建设 红旗河沟
  • phpcms适合做什么网站清远网站seo公司
  • 公司网站开发实例中德合作项目
  • 拐角型网站网络营销方式变化的逻辑
  • 网站建设公司如何发展网页设计素材网站大全
  • 宿州做网站公司网站开发流程记住吧
  • 网站标题加后缀个人做网站犯法吗
  • 服装网站网络建设和硬件资源php服装商城网站建设
  • 一个主机可以建设多少个网站建筑资料软件
  • 如何给网站增加关键词网站建设dream
  • 公司网站开发实训报告做旅行社网站的
  • 家政服务网站做推广有效果吗wordpress入站密码
  • 建设网站项目概况国家高新技术企业
  • 常德网站建设技术杭州做网站的公司哪些比较好
  • 南京哪家网站建设比较好设计网页页面
  • 女生做网站运营累不累网络文化经营许可证有效期几年
  • 陕西省建设资格注册中心网站即墨网站建设哪家好
  • 专业网站建设需要多少钱论坛网站免费建设模板下载
  • 成都网站建设推来客今天的新闻联播直播
  • 在建设银行网站上能看到自己贷款么360营销推广
  • 德阳做网站的公司wordpress原创免费主题