1. What are the common HTTP error codes? What’s the difference between 304 and 401?
-
404– (not found) The server could not find the requested page
-
400– Bad request (error request) server does not understand the syntax of the request
-
500– (internal server error) The server encountered an error and could not complete the request
-
304– Belongs to a redirect. The requested page has not been modified since the last request. When the server returns this response, the web page content is not returned.
-
401– Not authorized. The request requires authentication. The server may return this response for a web page that requires login
2. Do you know about Web injection attacks, explain the principles, and how well you know about the two common attacks (XSS and CSRF)?
Reference: www.cnblogs.com/morethink/p…
3. What is the difference between arrow functions and ordinary functions
- Arrow functions are anonymous and cannot be used as constructors. New cannot be used.
- Arrow functions can’t bind arguments and use rest arguments instead.
- Arrow functions have no stereotype attributes.
- The arrow function’s this always points to its context’s this, and there is no way to change its reference. The normal function’s this points to the object calling it.
- Arrow functions cannot bind this and will capture the value of this of their context as their own.
4. Could you elaborate on your understanding of the vue2.0 life cycle?
There are 8 stages: before/after creation, before/after loading, before/after updating, and before/after destruction.
- Before and after creation: In the beforeCreated phase, the mount element EL and ∗∗data object ∗data of the VUE instance are both undefined and not initialized. In the created phase, the vue instance’s data object, data, el and **data are undefined and not initialized. In the created stage, the data object data of the VUE instance is available, while EL and ∗∗data object ∗data are undefined and not initialized. In the Created phase, the vUE instance’s data object, Data, is available, but el is not.
- Before/After loading: In the beforeMount phase, the vue instance’s $EL and data are initialized, but the previously virtual DOM node is still mounted, and data.message has not been replaced. In mounted phase, vue instance is mounted and data.message is successfully rendered.
- Before/After update: When data changes, the beforeUpdate and updated methods are triggered.
- Before/after destruction: After the destory method is executed, the change to data does not trigger the periodic function, indicating that the vue instance has been unbound from the event listening and dom, but the DOM structure still exists.
5. What are the data transfer methods between vue parent and child components?
The father provides the data to the son via the props property; The son triggers his own event through on tying his father event, then on tying his father event, then on tying his father event, and then through emit
6. Add styles to center multiple lines of text horizontally and vertically
<p style="height:100px; width:100px; </span> </p>Copy the code
p{
display: flex;
justify-content: center;
align-items: center;
}
Copy the code
7. Say the following code print order
const promise=new Promise((resolve,reject)=>{ console.log(1); resolve(); setTimeout(()=>{ console.log(2); }, 0); }); promise.then(()=>{ console.log(3); }); console.log(4);Copy the code
Results: 1432
Reference: event loops
8. Implement the function to remove duplicate characters from the input string
function removeRepeat(str){ return [...new Set(str)].join(""); } removeRepeat('aabbcc') // returns ABC removeRepeat(' ABC ') // returns ABC removeRepeat('abcabc') // returns ABCCopy the code
9. How to deal with cross-domain
- Cross domains via JSONP
- Cross-domain Resource Sharing (CORS)
- Nginx agents cross domains
Reference: www.jianshu.com/p/9f0ffb551… Or segmentfault.com/a/119000001…
10. When is keep-alive used?
Keep-alive is a built-in component of Vue that can preserve the state of contained components and avoid re-rendering. It has the following features:
It is used together with routing and dynamic components to cache components. Provide include and exclude attributes. Both of them support strings or regular expressions. Include indicates that only components with matching names will be cached, and exclude indicates that components with matching names will not be cached. The hook function activated is activated when a component is activated, and the hook function deactivated is activated when a component is removed.
11. Talk about loading on demand — routing lazy loading.
Vue-router Implements lazy route loading (dynamic route loading)
Three ways. The first type: vUE asynchronous component technology ==== asynchronous loading, VUe-router configures the route, using vUE asynchronous component technology, can achieve on-demand loading, however, in this case a component generates a JS file. The second type: lazy route loading (using import). The third type: Require.ensure () provided by Webpack, vue-router configures routing, using Webpack’s Require.Ensure technology, which can also be loaded on demand. In this case, multiple routes with the same chunkName are combined and packaged into a single JS file.
12. Componentization of projects.
Reference: blog.csdn.net/weixin_4327…
13. Watch, computed difference
- Computed: Used when an attribute is affected by multiple attributes. The most typical example of a computed item is a shopping cart at checkout time
- Watch: Used when one piece of data affects multiple pieces of data. Watch example: Search data
The difference between:
- Different data processing scenarios, listeners are suitable for one data affecting multiple data, and computational properties are suitable for one data affected by multiple data
- The calculated property is cacheable. The calculated value will not be executed repeatedly if there is no change, but watch will be executed repeatedly
- The listener option provides a more generic way to perform asynchronous or expensive operations
14. vue solt
Simply put, if the parent component needs to put some DOM inside the child component, will the DOM be displayed, not displayed, where it will be displayed, and how it will be displayed
15. What improvements did you make to the project?
- Use route lazy loading
- Packaging optimization
- Load third-party modules using CDN
- Lazy loading of images
- Third-party modules are loaded on demand
- The compression code
16. Several states of VUex.
- State: Data structure that defines the State of the application, where the default initial State can be set.
- Getter: Allows the component to get data from the Store. The mapGetters helper function simply maps the getters in the Store to local computed properties.
- Mutation: is the only method that changes the state in the store, and must be a synchronization function.
- Action: Used to commit mutation rather than directly change the state, and can include any asynchronous operation.
- Module: Allows you to split a single Store into multiple stores and Store them simultaneously in a single state tree.
17. Tell me about the difficulties of your project.
Business logic is complex and changeable