Home>Article>Web Front-end> How to use global functions to pass parameters between uniapp components

How to use global functions to pass parameters between uniapp components

coldplay.xixi
coldplay.xixi Original
2020-12-09 15:11:44 3913browse

The method of using global functions to pass parameters between uniapp components: 1. Listen to the global function in the component that receives the parameters; 2. Register the global function in the component that passes the parameters, the code is [uni.$emit( 'Function name', parameters)].

How to use global functions to pass parameters between uniapp components

The operating environment of this tutorial: windows7 system, uni-app2.5.1 version, Dell G3 computer.

Recommended (free):uni-app development tutorial

Utilize global functions between uniapp components Method of passing parameters:

1. Listen to the global function in the component that receives the parameters

uni.$on('函数名',(形参数)=>{ ... });

2. Register the global function in the component that passes the parameters

uni.$emit('function name', parameters)

Code example:

Receive parameters:

  

Pass parameters:

  

Related free learning recommendations:Programming videos

The above is the detailed content of How to use global functions to pass parameters between uniapp components. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn