Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problems encountered in the development of Mini Program

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

The editor of this article introduces in detail "how to solve the problems encountered in the development of Mini Program". The content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to solve the problems encountered in the development of Mini Program" can help you solve your doubts. Let's follow the editor's ideas slowly and deeply, together to learn new knowledge.

Summary of questions:

(1) the problem of using rpx at the height of the separator

There will be a split line directly in the two adjacent messages, the height of the line will be set to 1rpx, the separation line before the first and second line is not displayed, but the other shows that the properties of the split line are the same, and in different mobile phones (different resolutions) do not show the split line is also different, some resolution several split lines do not show, do not know whether this is the simulator bug or rpx bug. Solution: the height size unit of the dividing line uses px, which solves this problem.

(2) Page registration problem

This error may be easy to understand, page registration error. Pages are rendered through Page objects. The js file corresponding to each page must create a page. The easiest way is to write Page ({}) under the js file. In page, the lifecycle of page rendering and data processing are managed, and events are completed here. The cause of this error is usually that the page has just been created and the js file has been processed or forgotten to deal with.

Solution: get into the habit of creating Page in the js file while creating the page.

(3) Page route error

When a route is called repeatedly, the way to deal with it is to delete a route, delete a component, or delete a wx.navigateTo.

4) Don't have * Handle in current page.

In fact, this kind of problem usually occurs when we define some handling events in wxml, but this error occurs if we do not implement the handling method of this event in the js file. So we follow the prompts to add event handling to the js file

Solution: don't miss any method implementation that invokes the event

(5) tabBar setting does not display

There are many reasons for not displaying tabBar. Find this error and go directly to the app.json file.

The page is not registered with app.json

TabBar is not displayed due to misspelling. Write the uppercase letter B in lowercase, resulting in tabBar not displaying.

The pagePath field is not written in the list of tabBar, or the page in pagePath is not registered

The pagePath specified page of tabBar's list is not written on the first page of the registration page. WeChat Mini Programs's logic is that the first page in "pages" is the home page, that is, the first page displayed after the program starts. If the pagePath of tabBar's list does not specify the first page of pages, of course, tabBar will not be displayed.

The number of tabBar is less than two or more than five, and the Wechat official clearly stipulates that there are at least two and a maximum of five tabBar. More than or less than tabBar will not be displayed.

(6) wx.navigateTo cannot open the page

An application can only open five pages at a time, and wx.navigateTo cannot open a new page normally after it has already opened five pages. Avoid multiple levels of interaction, or use wx.redirectTo

(7) Local resources cannot be obtained through css

Background-image: you can use web pictures, or base64, or use tags

(8) Page data transmission

WeChat Mini Programs routing (page jump) is realized through the components in API wx.navigateTo or wxml. No matter which implementation there is, an important parameter is url, which specifies the page to be redirected, and the data transfer between pages is also realized through url, which is somewhat similar to the get network request we use, splicing the parameters after the address of the interface to be redirected and using "?" Connect. Then append the data to be passed in the "?" in the form of keys and values. Later, multiple parameters are matched directly with "&". It can be written like this.

{{item.title}} {{item.message}} {{item.time}} {{item.count}}

The data is received in the page of the js file. In the page life cycle, there is an onLoad function that initializes the data. The onLoad function has a parameter options, and we can get the data through key, as follows

OnLoad:function (options) {/ / parameters brought by page initialization options for page jump console.log (options.title) / / here is the receiving parameter console.log (options.message)}

In this way, the function of data transfer between pages is realized.

After reading this, the article "how to solve the problems encountered in Mini Program Development" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, welcome to follow 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report