In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
The knowledge of this article "how to achieve component communication in WeChat Mini Programs" is not quite understood by most people, so the editor summarizes the following contents, with detailed contents and clear steps, which can be used for reference. I hope you can get something after reading this article. Let's take a look at this "how to achieve component communication in WeChat Mini Programs" article.
(1) the parent component passes values to the child components:
Pass parameters to subcomponents through title=' {{title}}'
Subcomponent receive parameters:
Component ({properties: {title: {/ / attribute name type: Number, / / required) type: String,// currently accepts String, Number, Boolean, Object, Array, null (for any type)}, fn: {type: Function,}, data: {} Methods: {/ / the child component calls the parent component method childFn () {console.log (this.data.title) this.triggerEvent ("fn") / / the triggerEvent function accepts three values: event name, data, option value})
When methods uses title, this.data.title can get it directly.
Transfer methods to subcomponents through bind:fn='fn'
Method also defines a new method in properties receive, methods, this.triggerEvent ("fn") receives the method passed by the parent component
(2) the parent component invokes the child component data and method:
First get the component in the js onReady lifecycle of the parent component
OnReady: function () {/ / get popup component this.header= this.selectComponent ("# header");}
For example, to call a function method of a subcomponent
/ / call the sub-assembly method fn () {this.header.fn () / / sub-assembly method}. The above is about "how to implement component communication in WeChat Mini Programs". I believe you all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to learn more about the relevant knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.