网站要不要改版知乎 wordpress
news/
2025/9/24 5:12:40/
文章来源:
网站要不要改版,知乎 wordpress,深圳宝安区网站建设,字体设计艺术字1.父子传值#xff0c;父组件通过属性的方式去给子组件传递值#xff0c;子组件在properties属性去接收父组件传递过来的值#xff1a;
父组件部分#xff1a;
view classpcolorcustomer idchild bind:changSexchangSex…1.父子传值父组件通过属性的方式去给子组件传递值子组件在properties属性去接收父组件传递过来的值
父组件部分
view classpcolorcustomer idchild bind:changSexchangSex sex{{sex}} checked{{checked}}/customerview父组件的值{{sex}}/view
/view
子组件部分
properties: {sex:{type:String,value:女},checked:{type:Boolean,value:false}},通过 this.triggerEvent(changSex,女)去修改父组件的值
2.组件之间的传值
需要使用pubsub-js这个插件下载npm install pubsub-js
在组件1 引入import PubSup from pubsub-js 通过PubSup.publish(info,{name:zhansgan,age:20});去传递值
在组建2 引入import PubSup from pubsub-js在生命周期去接收 lifetimes:{attached() {PubSup.subscribe(info,(name,value){console.log(name,value)})}},
3.页面间的传值
跳转页面
jump:function() {wx.navigateTo({url: /pages/list/list,events:{send1:(e){console.log(e)}},success:(res){console.log(res)res.eventChannel.emit(send,{name:zhangsan})}})}, 接收页面
onLoad() {const openerEventChannel this.getOpenerEventChannel();console.log(111)openerEventChannel.on(send,(res){console.log(res)})openerEventChannel.emit(send1,{age:10})}
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/914927.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!