2015-07-22 Knowledge Point Collation

Source: Internet
Author: User

1, Fs.rename (Oldpath,newpath,callback) and Fs.renamesync (Oldpath,newpath) Usage Summary:

I was in the uploading of pictures when I met Fs.rename (Oldpath,newpath,callback) and Fs.renamesync (Oldpath,newpath), in fact, two can be implemented to the file renaming, and I then transmitted the data format is problematic, Think that can only be used asynchronously, can not use synchronization, after experimental proof, both methods can be used. But what is the difference between these two methods? My understanding of synchronization: If the request takes a while to return the information, then the process will wait until the return message continues, and asynchronously, the process does not have to wait, but continues to perform the following operations, which increases the efficiency of asynchronous execution. Synchronization is easy to understand, synchronous code reading will be more smooth, or more advocating synchronization, because this event is not complex, synchronization if you can achieve synchronization.

2, Fs.exists (Path,callback) and Fs.existssync (path) and the above problem, in order to facilitate the readability of the code, it is best to use synchronous call method to determine whether the folder exists, of course, both implementations can be achieved.

3, naming norms, the general global variables are g_xxx, the method name is the beginning of lowercase, the verb in front, there are writing format, note line indentation and parentheses. Try not to repeat the code, if there is a large number of code duplication, please extract the code, if the variable is very long, need to use a lot of places, then, the variable redefined. It is best to write code using the framework, which facilitates code management and increases the reusability of the code. When using the path, configure it in the config file and do not use another routing table to find the path.

4, the path, attention to string concatenation, it is possible to enter the escape character/, then the path will be problematic, so with the URL splicing point to join, the framework provides a path.jion (a, B) This method, need to change. If it is Ajax, request the value of the header, then also pay attention to the value, possibly? , then this path will go wrong, so use Jquery.url () to stitch the strings together.

5. When defining global variables, you should pay attention to resetting the variables (empty).

6, through Easyui-treegrid, select the row to get and edit the line gets as follows:

var node=$ ("#table_master"). Treegrid ("getselected"); var Name = node. Name;console.info (Name)//If you click on a new line, the print is undefined, so getselected cannot get the value of the edit row, it can only//get the information selected for non-edit lines. if (node. buildingoid!=g_newrecordoid) {    var Name = node. Name;    } else{    var editors=$ ("#table_master"). Treegrid ("Geteditors", g_newrecordoid);    var Name = Editors[1].target[0].value;    Console.info (editors)}//the value of the edit row can be obtained by geteditors, Name = Editors[1].target[0].value;

  

7, write code must be a lot of analysis of requirements, to understand the project is what to do. This is important. Work slowly, strengthen the basic knowledge point of learning, careful, positive, upward.

2015-07-22 Knowledge Point Collation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.