Home >Web Front-end >Vue.js >What is the difference between vue3.0 and vue2.0?
Difference: In vue2.0, no matter how big the data is, an observer will be created for it at the beginning; when the data is large, this may cause obvious performance pressure when the page is loaded. Vue3.0 will only create observers for "the data used to render the initial visible part", and vue3.0's observers are more efficient.
##The difference between vue3.0 and 2.0
Vue-cli3.0 in 8 It was officially released on March 11th. After reading the comments, the compatibility is not very good and there are many changes in the commands. I am not particularly optimistic. Compared with vue2.0, the advantages of the release of vue3.0 are mainly reflected in: Faster, smaller, easier to maintain, easier to native, easier for developers;faster 1. Virtual DOM is completely rewritten, mounting & patching is 100% faster ;
2. More compile-time reminders to reduce runtime overhead;
3. Proxy-based observer mechanism to meet full language coverage and better performance;
4. Abandon Object. defineProperty, use faster native Proxy;
5. Component instance initialization speed is increased by 100%;
6. Speed is doubled/memory usage is reduced by half;
is smaller 1. Tree-shaking is more friendly;
2. New core runtime: ~ 10kb gzipped;
Note:php Chinese online work has also begun to teach the latest version of the vue course. Interested friends can learn more .
Installation
npm install -g vue@cliCreate project file:
vue create project //项目的名称============= =======
The difference between vue2 and vue3
1. Common commandsvue -V Check the local vue version2. Official document3.0: https://cli.vuejs.org/zh/3. Create file3.0: vue create enter the project file folder to create the project. 2.0: vue init webpack4. Start the project3.0 Start npm run serve2.0 Start npm run devbuild Gone, the config is gone, oh, and the most important point is that node-model is automatically downloaded when installing the 3.0 project. Create a vue.config.js in the root directory
module.exports = { baseUrl: process.env.NODE_ENV === 'production' ? '/online/' : '/', // outputDir: 在npm run build时 生成文件的目录 type:string, default:'dist' // outputDir: 'dist', // pages:{ type:Object,Default:undfind } devServer: { port: 8888, // 端口号 host: 'localhost', https: false, // https:{type:Boolean} open: true, //配置自动启动浏览器 // proxy: 'http://localhost:4000' // 配置跨域处理,只有一个代理 proxy: { '/api': { target: '<url>', ws: true, changeOrigin: true }, '/foo': { target: '<other_url>' } }, // 配置多个代理 } }==================
The difference between Vue3.0 and Vue2.0
1. Lazy observation is performed by default. In version 2.x, no matter how big the data is, observers will be created for it at the beginning. When the data is large, this can cause significant performance pressure when the page loads. In version 3.x, observers will only be created for "data used to render the initial visible part", and 3.x observers are more efficient. 2. More accurate change notifications. In proportion: in version 2.x, when you use Vue.set to add a property to an object, all watchers of this object will be re-run; in version 3.x, only those that depend on that property The watcher will run again. 3. 3.0 has newly added support for TypeScript and PWA4. Some commands have changed: Download and install npm install -g vue@cliDeleted vue listCreate project vue createStart project npm run serve5. The default project directory structure has also changed: The configuration file directory, config and build folders were removedThe static folder was removed, the public folder was added, and index.html was moved to publicIn the src folder A new views folder is added for classifying view components and public componentsRelated recommendations:For more programming-related knowledge, please visit:
2020 Summary of front-end vue interview questions (with answers) )
vue tutorial recommendation: The latest 5 vue.js video tutorial selections in 2020
Programming Teaching! !
The above is the detailed content of What is the difference between vue3.0 and vue2.0?. For more information, please follow other related articles on the PHP Chinese website!