Unified Naming convention:
If you use vUE, follow the naming convention of vue, because most people do this, easy to manage, recommend a copy
Vue development naming convention – Front-end development Log – SegmentFault Think no
If you use typescript, use typescript naming conventions
What are standard rules for TypeScript code formatting schemes?
Guide to general page development specifications
Development Specification Guide
There are no restrictions on the interface, the file name, the architecture, you have to be consistent with the back end. You can name it camel, you can name it slippage. Development documents, mainly API documents, currently using Postman, mainly record interface, only for testing. But this is far from enough, or to improve the API documentation, experience will have the following problems will be bugs, normally, the back end will only tell you the return of SUCCESS, you only see the return of SUCCESS, if you just do this, there will still be problems,success will also have a variety of cases, Maybe you only know one case, and there will be problems later in the development. Back-end refinement interface documentation.
The format of API documents should be divided into complete and fail. For general fail, the backend will return by default. For others, special processing is required
Json default format
{
"data": {},"status":"0"."message":""
}
Copy the code
Let’s start with the status code
HTTP status code details
200,302,404 are common, and the status returned by the back end is also different, which needs to be negotiated with the back end, simply 0 and 1. 0 is fail, 1 is complete, for example, permission control, no access, or not enough access, only part of the access, need to negotiate. For example, the format of the data returned by the back end may be incomplete. It may return “” or [], or the key may not return at all. Then the front end will throw an exception.
3. Ajax request conventions,get or POST:
At present, I always use POST. Post is more secure because the data length is unlimited and cannot be cached.
4. Unified transmission format:
Post request, submission format may be formData form may be JSON format, generally used in these two, background may use formData more convenient, but not flexible, because the former developer used formData, I and back-end development debugging is very inconvenient. Json is more flexible, and I recommend json.
5. Picture Path:
Some project image path is the front-end control, divided into absolute and relative paths, local resources are generally use relative paths, but some resources may can’t use relative paths, such as our backend is now seven NiuYun stored images, if it is a web site might be domain name is fixed, this is relatively simple, Front-end request image resources should be able to encapsulate the public position, I don’t know which way can be encapsulated, I use the vue, axios request picture fields come back and the back-end agreed, don’t know how to encapsulate public image resource address, my side is to let the back-end to encapsulate, image size and back-end control, if the front is it better to control
6. Picture upload:
Base64 encoding upload, I like this, because you can do compression, you can do watermarking but the back end feels too complicated, qiuniuyun has compression by default, the form upload image can also, and then upload the image, the details page will see the image, here to emphasize, the image path may have problems
SVN or git:
I’m using Git here.
8. Try to have documents for each bug modification:
Otherwise, the SVN can only search one by one, and the SVN must have message submission.
9. Local data:
Permanent use of local storage, temporary use of session storage, mobile wechat cookie store those authorized information, so wechat here do not use cookies
10. Agreement with design sister:
PNG is used for the pictures. Before sending the pictures to me, compress them and pack them into folders (if you can name the pictures in English, please do so) or SVN format. The size of iphone7 is good for mobile terminal development. 750px, rem on the front end. I had her mark the size, too, because who knows how big the font is, what the color is. PxCook – the most efficient and easy to use automatic annotation tool, design and development collaboration tool has interactive places also let her draw. Or you can make one. It’s not pretty.
11. Agreements with products:
How to do the interaction, where to use it, always have a prototype. Product requirements must be documented, and without documented requirements, you don’t do it. Whenever he says, “There’s no need, I didn’t ask for it,” you’re on the hook.
Let me introduce the address of Zhihu