current position:Home>Some thoughts on small program development
Some thoughts on small program development
2021-08-27 00:12:44 【hyman】
This is my participation 8 The fourth of the yuegengwen challenge 20 God , Check out the activity details :8 Yuegengwen challenge
Some thoughts on small program development
One 、 Before project development
1、 Project architecture phase , Subcontracting shall be decided as early as possible according to the project volume .
For larger volumes 、 For applet projects with more pages , The advantage of subcontracting is :
- Optimize the overall loading speed of applet ;
- Optimize package size , Avoid exceeding code package limits ;
- Conducive to project management , Quickly locate the page location ;
2、 Picture material in the project 、 Public Large js And so on , Upload to the cloud as soon as possible , Local icon Make folder classification according to the page to facilitate management .
- Whether online or local , Strictly control the size of the picture , Try to avoid the appearance of 100KB The picture above , May seriously affect page performance ;
- Local icon Sub folder management , Quick positioning when replacement or deletion is needed , Avoid redundancy icon Accumulation and waste of time ;
3、 All interfaces or main list details , Handle the interface return exception logic as soon as possible , Agree the exception throwing method with the backend .
- scene 1: Small program end session_key Be overdue
take session_key The logic of expired re acquisition is encapsulated into the public js in , Each interface gets the exception value again according to the exception value agreed with the back end
- scene 2: The backend login status has expired
According to the business scenario , Return to the login page or throw an exception
- scene 3: Other mistakes
According to the business scenario , Return to the login page or throw an exception
I personally believe that the return values and processing methods of different scenarios should be agreed with the backend before development , Adding after the main logic development is completed will waste unnecessary working time . ### Two 、 Project under development
4、 Title of all fixed frames 、 If the content exceeds the text length .
- The most common front end style bug One of , If the text length exceeds the normal range, you should always pay attention to adding processing logic in the process of static page development , Avoid waste of work in the testing stage ;
5、 All lists use scroll-view, Drop down loading events should take into account the rendering speed of resources per page , Optimize the user experience .
- All need to use pull-up loading 、 The drop-down refresh 、 Anchor positioning page , Static page development will use scroll-view To write ;
- For pull-up load paging list pages , When considering fast sliding scroll-view Often get stuck and pull again to display the content of the next page , To optimize the user experience interactively , Such as loading icons at the bottom of the page , Interface loading The explicit and implicit time of ;
6、 all image Add... According to the actual use scenario mode.
- The most common front end style bug The second , Static page development process should think of here image How to display , Whether to cut 、 How to deal with deformation , use widthFix、aspectFit And so on mode;
7、 When doing page Jump , Consider which routing method to use .
- Jump between list and details 、 Normal pages and tab Page Jump and other scenes , You can't just use navigateTo, Consider the actual application scenario , Think about whether the current page should be destroyed , Note that the page stack is stacked after the current operation , Flexible use redirectTo、reLaunch And other routing methods ;
- List page message read unread status reset 、 On the details page, pay attention to the button status on the back list page and other scenarios , The development process should take into account , Instead of waiting for the tester to ask , Sub page is a common method for data management of superior pages :
changeIndexInE: function(){
let pages = getCurrentPages(); // Get the page stack
let prevPage = pages[pages.length - 2]; // Get the parent page
prevPage.setData({
// This is the parent page that needs to be changed data
})
}
Copy code
8、 Flexible use onHide and onUnload.
- onHide: When from the current A Page Jump to another page , be A The page is hidden ;
- onUnload: The current in the A page , When you click the back button , be A Page uninstall ;
Used in this page storage Logic is no longer useful , When unloading pages or hiding pages, empty them in time to avoid memory occupation ;
Two 、 Small problems
9、view If there is... In the label text label ,text The beginning of the label is not on the same line as the closing label , Will hold up view label .
- view Used in text label , Start and close on the same line , Otherwise, there may be blank lines that cannot be deleted anyway
correct :
<view>
<text> I am content. </text>
</view>
Copy code
error :
<view>
<text>
I am content.
</text>
</view>
Copy code
10、 Applet gettime Method , Real machine ios There will be compatibility problems at the end , Must take 2019-04-30 Replace with 2019/04/30 Can be used .
The summary is one-sided , I mainly want to remind myself that you can't just focus on the current small functions in the coding process , You should also expand your thinking at any time and think of the relevant parts before and after the function point , Make a good connection between the current function point and its corresponding function point , It will help you save a lot of development time and bug Modify workload , Share with everyone :)
copyright notice
author[hyman],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2021/08/20210827001240088k.html
The sidebar is recommended
- Crazy blessing! Tencent boss's "million JVM learning notes", real topic of Huawei Java interview 2020-2021
- JS JavaScript how to get the subscript of a value in the array
- How to implement injection in vuex source code?
- One line of code teaches you how to advertise on Tanabata Valentine's Day - Animation 3D photo album (music + text) HTML + CSS + JavaScript
- An article disassembles the pyramid architecture behind the gamefi outbreak
- BEM - a front-end CSS naming methodology
- Another ruthless character fell by 40000, which was "more beautiful" than Passat and maiteng, and didn't lose BMW
- Huang Lei basks in Zhang Yixing's album, and the relationship between teachers and apprentices is no less than that in the past. Netizens envy Huang Lei
- Zhou Shen sang the theme song of the film "summer friends and sunny days" in mainland China. Netizen: endless aftertaste
- August 23, 2021 Daily: less than three years after its establishment, Google dissolved the health department
guess what you like
-
The female doctor of Southeast University is no less beautiful than the female star. She has been married four times, and her personal experience has been controversial
-
There are many potential safety hazards in Chinese restaurant. The top of the program recording shed collapses, and the artist will fall down if he is careless
-
Introduction to flex flexible layout in CSS -- learning notes
-
CSS learning notes - Flex layout (Ruan Yifeng tutorial summary)
-
Today, let's talk about the arrow function of ES6
-
Unwilling to cooperate with Wang Yibo again, Zhao Liying's fans went on a collective strike and made a public apology in less than a day
-
Zheng Shuang's 30th birthday is deserted. Chen Jia has been sending blessings for ten years. Is it really just forgetting to make friends?
-
Asynchronous solution async await
-
Analysis and expansion of Vue infinite scroll source code
-
"The story of huiyeji" -- people are always greedy, and fairies should be spotless!
Random recommended
- Installing Vue devtool for chrome and Firefox
- Basic usage of JS object
- 1. JavaScript variable promotion mechanism
- Two easy-to-use animation JS that make the page move
- Front end Engineering - scaffold
- Java SQL Server intelligent fixed asset management, back end + front end + mobile end
- Mediator pattern of JavaScript Design Pattern
- Array de duplication problem solution - Nan recognition problem
- New choice for app development: building mobile applications using Vue native
- Vieira officially terminated his contract and left the team. The national security club sent blessings to him
- Less than 200000 to buy a Ford RV? 2.0T gasoline / diesel power, horizontal bed / longitudinal bed layout can be selected
- We are fearless in epidemic prevention and control -- pay tribute to the front-line workers of epidemic prevention!
- Front end, netty framework tutorial
- The wireless charging of SAIC Roewe rx5 plus is so easy to use!
- Upload and preview pictures with JavaScript, and summarize the most complete mybatis core configuration file
- Ajax foundation - HTTP foundation of interview essential knowledge
- Cloud lesson | explain in detail how Huawei cloud exclusive load balancing charges
- [JS] 10. Closure application (loop processing)
- Left hand IRR, right hand NPV, master the password of getting rich