[H5 and Vue stacking problem collection]

Function promotion six

When the js engine parses javascript code, it will pre-process the statement blocks beginning with var and function.
1. Function promotion
2. Variable promotion: only declaration promotion, no assignment promotion
3. When function declaration name and variable name When repeated: function hoisting variables are not hoisted
4. function expressions are not hoisted
5. hoisting is not out of scope

Function advancement Under normal circumstances: variable promotion is not included
1. If two variable names are repeated, the latter will overwrite the former
2. If two function declarations are repeated, the latter will overwrite the former
3. If two function expressions are repeated, they are close
4. If the function declaration and function expression are duplicated, the expression overrides the declaration. 5.
If the function declaration duplicates the variable name, the variable name overrides the function (function declaration)
6. If the function expression duplicates the variable name , the rear covers the front

函数表达式不能提升,变量比声明优先级高,表达式比声明优先级高,变量和表达式,后边会覆盖前边

official:

Before the variable name < after the variable name Before the function
name < after the function name < function expression (proximity principle) before the function
expression < after the variable name function name
< variable name

renderings

extension:

The difference between var let and const

var has no scope problem, and can be assigned anywhere.
let has scope problems, limited to curly braces, and can be modified.
const can only declare constants, and cannot be assigned or modified after declaration

The pointing problem of this (this pointing in the function)

  1. In the constructor, this points to the instantiated object
  2. In an object function, this points to the current object
  3. In ordinary functions, this points to window
  4. In the event function, this points to the event source,
    this points to the object, and the object points to the characteristics and behaviors
  5. In the timer function, this points to window
  6. Call the function in the instantiated function, this points to the instantiated object, call the function in the prototype object, this points to the prototype object
  7. If the element of the array is a function, in this function this points to the current array
  8. In the prototype function, if the instantiated object calls the function this points to the instantiated object
  9. If the prototype object calls the function, this executes the prototype object
  10. The arrow function does not have this, and the arrow function always points to the parent

expand

Prototype object pointing problem

prototype object

Any function has a prototype attribute, which itself is an object, which we call a prototype.
The relationship between constructor instantiation object and prototype? (Key)
Conclusion 1: Any function has a prototype attribute, which itself is an object, which we call a prototype.
Conclusion 1: The constructor is also a function, and it also has a prototype attribute. It is an object itself, called a prototype.
Conclusion 3: The properties and methods on the prototype object of the constructor can be inherited by the instantiated object (key point) Conclusion
4: Any object has a constructor attribute, and the constructor attribute of the instantiated object points to the constructor
Conclusion 5: The prototype is also an object , also has the constructor attribute, the constructor attribute of the prototype object points to the constructor
conclusion six: any object __proto__ attribute, the (_ _ ) proto (_ _) attribute of the instantiated object points to the prototype of the constructor
Prototype is the attribute object of the prototype object The properties of the object (function) prototype can be found

Pointing to the prototype object:

insert image description here

Six ways of CSS

1. Object.style('color','red')
2. Object.className('new name')
3. Object.setAttribute("style", "style")
4. Object.setAttribute("class", " Class name")
5. Object.style.setProperty("css property", "css property value")
6. Object.style.cssText = "style"

operator precedence

算术运算,
一元运算:前置++ 先加后用,后置++ 先用后加,前置- - ,后置- -,
逻辑运算:1,&&逻辑与 ||逻辑或  ! 逻辑非 比较运算

> <  >= <= == ====,赋值运算,
优先级 括号>点运算符>一元运算符>算数运算符>(关系)比较运算符>逻辑运算符>赋值运算符

先&& 后||

Common post request parameters

  1. form-data:
    Equivalent to multipart/form-data in the http request, it will process the data of the form as a message, with labels as units and separated by separators. Both key-value pairs and files can be uploaded. When the uploaded field is a file, there will be Content-Type to indicate the file type; content-disposition is used to describe some information of the field; due to
    boundary isolation, multipart/form-data can upload both files and uploads Key-value pairs, it uses key-value pairs, so multiple files can be uploaded.

  2. x-www-form-urlencoded:
    equivalent to application/x-www-from-urlencoded, will convert the data in the form into key-value pairs, for example, name=java&age = 23

  3. raw
    can upload text in any format, such as text, json, xml, html, etc.

  4. binary
    is equivalent to Content-Type: application/octet-stream. From the literal meaning, only binary data can be uploaded. It is usually used to upload files. Since there is no key value, only one file can be uploaded at a time.

The difference between multipart/form-data and x-www-form-urlencoded
multipart/form-data: You can upload binary data such as files, or upload form key-value pairs, but it will be converted into a message in the end;
x-www-form- urlencoded: Only key-value pairs can be uploaded, and the key-value pairs are separated by intervals.

Standard answer for mvc and mvvm

  1. MVC (Model model-View view-Controller controller) is a layered development concept when the front and back ends are not separated.
    The View view layer is the client interface that users can see and interact with, such as the graphical interface of the desktop application, the web page rendered by the browser, etc.; the Model data operation layer is used for calculation, verification, processing
    and providing data, but not Interact directly with the user;
    the Controller business logic layer is responsible for collecting the data input by the user, requesting data from the relevant model and returning the corresponding view to complete the interaction request.

  2. MVVM (Model model-View view-ViewModel view model or scheduler) is a front-end layered development concept after the front-end and back-end separation.
    All pages in the front end are collectively referred to as the View view layer in MVC.
    Its most important feature is two-way data binding, and it also includes some features such as dependency injection, routing configuration, and data templates.
    The reason for the separation of the front and back ends is that with the development of technology, the market and industry have higher and higher requirements for the front end.
    The front-end concept of the unseparated era is similar to "just use it"...
    M in MVVM is also the data operation layer, that is, the part that processes the data that needs to be rendered in the page. There is an essential difference between this M and the M in MVC. The Model layer in MVC It is a real service database, and the data of the Model layer in MVVM is all requested from the server.
    The V in MVVM is also the View view layer, that is, the client interface that users can see and interact with.
    The VM in MVVM is the core concept in MVVM. It is a scheduler, which realizes two-way data binding, and can render the data of the Model data operation layer to the View view layer. At the same time, the data of the View view layer can be automatically synchronized when it changes. In the Model layer, VM frees the hands of front-end programmers. Front-end programmers no longer need to perform unnecessary DOM operations, and only need to care about the front-end business logic.

There are 5 HTTP request methods

The difference between route and router

Router is a jump page.
Route accepts parameters.
Each router has a route object . Router is an object of VueRouter. A router instance object
is obtained through Vue.use(VueRouter) and the VueRouter constructor . This object is a global one.
The object that contains all the routes contains a number of key objects and properties.
route is a route object for jumping, each route will have a route object, which is a local object, and you can get the corresponding name, path, params, query, etc. $router.push({path:'/path'}
) ; The essence is to add a route to the history stack. In our opinion, it is to switch the route, but the essence is to add a history record
$router.replace({path:'/path'}); replace the route, no history

The difference between params passing parameters and query passing parameters

The params parameter will not be displayed in the address bar, but the query will be displayed.
After the webpage is refreshed, the params parameter will not exist

optimization of vue

Advantages: good user experience, separation of front and back ends, front-end componentization
Disadvantages: the first loading consumes a lot of resources and takes up a lot of memory, which is not conducive to SEO optimization and difficult to implement navigation

route guard

The difference between beforeforEach() and afterterforEach()
beforeEach
in routingbefore the jumpTrigger, the parameters include to, from, next (parameters will be introduced separately), this hook is mainly used for login verification
beforeResolve (2.5+)
This hook is similar to beforeEach, it is also triggered before the route jumps, the parameters are also to, from , next three, the difference between beforeEach and beforeEach refer to the official website.
afterEach
is in routingAfter the jump is completeTriggered, the parameters include to, from, it happens after beforeEach and beforeResolve, before beforeRouteEnter (guard in the component).

vue-cli, WeChat applet, uniapp-project prompt structure

insert image description here

insert image description here

insert image description here

坚定自己心之所向,无所畏惧,才能枪出如龙,

Guess you like

Origin blog.csdn.net/ytfty24124/article/details/128037866