Home > Web Front-end > uni-app > body text

How uniapp encapsulates public methods

coldplay.xixi
Release: 2020-12-14 17:49:53
Original
8112 people have browsed it

Implement the common method of uniapp encapsulation: first create uni-app and create a new page file; then create a new encapsulation file and define the encapsulation method; then call the method on the page; finally save the compilation preview.

How uniapp encapsulates public methods

The operating environment of this tutorial: windows7 system, uni-app2.5.1 version. This method is suitable for all brands of computers.

Recommended (free):uni-app development tutorial

Implementing uniapp encapsulation public methods:

1. Double-click to open the HBuilderX development tool, create the uni-app project and open it

How uniapp encapsulates public methods

2. Under the pages folder, create a new page file index .vue, and open

How uniapp encapsulates public methods

3, create a utils folder, and then create a new JavaScript file DateUtils.js

How uniapp encapsulates public methods

4. Open the newly created js file, define the function statusTime, and then return the date in the specified format

How uniapp encapsulates public methods

5. In the index.vue file, insert a picker element and bind it Properties and variables

How uniapp encapsulates public methods

6. In the <script></script> tag, import DateUtils and use

in the variable

How uniapp encapsulates public methods

7. Save the code and compile the code. Check the compilation effect in WeChat developer tools

How uniapp encapsulates public methods

Related free learning Recommended: Programming Video

The above is the detailed content of How uniapp encapsulates public methods. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!