Top 3: in the access address#

Problem Description:

When a button is clicked, we open a page, and the configuration parameters in this page can be done by passing the parameter through the URL of the page, similar to the following form.

http://www.cnblogs.com/kaituorensheng/p/3776527.html?name=gping&age=23

In this way, we usually use a lot of parameters between pages, but there is a hidden danger, that is, when the page is super long (I am not very clear here), the address will be reported 5** or 404 error.

Problem solving: We can solve this problem by changing the method of passing parameters. For example, the one we need to open is actually an iframe, so we can use the postMessage method.

The other one is the one we want to mention, by way of #, that we see all the time on the page, right? And ampersand, but # is not very common, and the most common usage scenario is hash addresses. So what is it capable of? As follows:

  • #Represents a location in a web page,#The character to the right of the symbol is the identifier for that position
  • Simple change#After the character, the page does not reload
  • HTTPNot included in the request#The following string

The last point is the one that can be used to solve our problem. Again, let’s try it with # :

Top 2: shallow array replication

This pit is shared by colleagues. Slice is a common operation for arrays. However, when we use it, we may ignore the fact that it is shallow copy, which results in some values being changed and other values being abnormal. For the record:

Come to think of it, or steal the soul artist’s work

Problems solved as above, usually pay more attention!

Top 1: inputThe Accept attribute of the tag

Problem description directly on the code:

<input type="file" accept="image/*" />

Very simple requirements, upload pictures. However, there is a problem that uploading pictures in Windows will be very slow. This slowness mainly refers to the slow startup of file manager. It usually takes 5s to 10s.

The main reason lies in the accept attribute, which means to accept all pictures, equivalent to a layer of filtering, but it is precisely because of this layer of filtering, resulting in slow. My guess is that it’s going to be compared one by one, so it’s going to degrade performance

Specify a specific image type:

<input type="file" accept="image/gif, image/jpeg"/>

conclusion

It is full of vitality week, this week is a little busy, busy digging and filling pits! I wish you all a bright and happy holiday ~

All right, so pay attention