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;
- Download and install npm install -g vue@cli
- Deleted vue list
- Create project vue create
- Start project npm run serve
- The default project directory structure has also changed:
- The configuration file directory, config and build folders have been removed
- Removed the static folder, added a public folder, and moved index.html to public
- Added a views folder in the src folder for classifying view components And public components
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@cli
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

You can add a function to the Vue button by binding the button in the HTML template to a method. Define the method and write function logic in the Vue instance.

The watch option in Vue.js allows developers to listen for changes in specific data. When the data changes, watch triggers a callback function to perform update views or other tasks. Its configuration options include immediate, which specifies whether to execute a callback immediately, and deep, which specifies whether to recursively listen to changes to objects or arrays.

Vue multi-page development is a way to build applications using the Vue.js framework, where the application is divided into separate pages: Code Maintenance: Splitting the application into multiple pages can make the code easier to manage and maintain. Modularity: Each page can be used as a separate module for easy reuse and replacement. Simple routing: Navigation between pages can be managed through simple routing configuration. SEO Optimization: Each page has its own URL, which helps SEO.

Vue.js has four methods to return to the previous page: $router.go(-1)$router.back() uses <router-link to="/" component window.history.back(), and the method selection depends on the scene.

There are three ways to refer to JS files in Vue.js: directly specify the path using the <script> tag;; dynamic import using the mounted() lifecycle hook; and importing through the Vuex state management library.

There are three common methods for Vue.js to traverse arrays and objects: the v-for directive is used to traverse each element and render templates; the v-bind directive can be used with v-for to dynamically set attribute values for each element; and the .map method can convert array elements into new arrays.

There are two ways to jump div elements in Vue: use Vue Router and add router-link component. Add the @click event listener and call this.$router.push() method to jump.
