The plan of adding, deleting, changing and searching Mini Program's form

there are many forms of additions, deletions, changes and queries in Mini Program"s project, and the following problems are encountered:

  1. form validation, required items, format requirements, etc. are now manually written functions for verification. Each page needs to write a lot of if else, separately, which is long and smelly. Is there any systematic solution?

             let error = ""
            if (!form.email){
                error = ""
            }else if (!tools_verify.checkStr(form.email,"email")){
                error = ""
            }else if(!form.password){
                error = ""
            } else {
                error = ""
            }
  2. selector picker, has many options. It usually jumps to another list page to search and select, with a value passed-get value-selected value-return obtained value, including data update and other operations, which is very tedious and time-consuming. Is there any good way to simplify this;
  3. form modification, update. Because when Mini Program jumps back to the page, if the data is not deliberately loaded and initialized in onShow, the data will be cached automatically, sometimes resulting in abnormal or disordered display. But all page entry requests are made, and the experience is quite poor, and loading, loads are slow everywhere. How to optimize?
Jan.25,2022

first question: https://github.com/skyvow/wx-. (found by the official plug-in community)
the second question is not quite understood. The official picker is too simple to meet your needs. Do you still need to jump to the page to get?
third question: I don't know if this is misunderstood. Do you want to say that if there are deletions and changes, brushing data from the database will increase wear and tear and load time?
if so, I think you can just manipulate the current part of the dataset. Delete and modify you on the one hand to send a request, on the other hand to add, delete and modify on the page, that's all, as long as you need to know whether the server operation has been successful or not.
there is also ( https://www.jianshu.com/p/21c.) this can be referenced. Mini Program's rendering of the page is also optimized

.

if you want to experience a good speed and quickly add code, it is certain that the front-end operation of the dataset does not change much, which is relatively fast, but there are still problems with Synchronize that you need to pay attention to. In short, don't regard it as writing a page, just think of it as writing an app on the client

.
Menu