Home  >  Article  >  Web Front-end  >  Vue 2.5 Level E new features and features shared

Vue 2.5 Level E new features and features shared

小云云
小云云Original
2018-01-20 17:11:331412browse

Vue 2.5 Level E is released. We will highlight some of the more important changes: better TypeScript integration, better error handling, better support for functional components in single-file components, and environment-independent server-side rendering. We hope they can help you.

We are excited to announce the release of Vue 2.5 Level E! This release includes several feature improvements and we recommend you check out the release notes for complete details. In this post, we’ll highlight some of the more important changes: better TypeScript integration, better error handling, better support for functional components in single-file components, and environment-independent server-side rendering.

Better TypeScript integration

Thanks to the help of the TypeScript team, 2.5 provides greatly improved type declarations that can Works with Vue's out-of-the-box API without requiring component class decorators. New type declarations can also make editor extensions such as Vetur more powerful and provide better Intellisense support for pure JavaScript users. For more details, please see our previous information about the changes (translated version).

Thanks to Daniel Rosenwasser from the TypeScript team for initiating the PR, and core team members Herrington Darkholme and Katashin for improvements and reviews.

Note: TypeScript users should also update the following packages to the latest versions to be compatible with type declarations: vue-router, vuex, vuex-router-sync and vue-class-component.

Better error handling

In 2.4 and earlier versions, we usually use the global config.errorHandleroption to handle the application Unexpected error in program. We also have the renderError component option to handle errors in render functions. However, we lack a mechanism to handle generic errors within specific parts of the application.

In 2.5, we introduced the new errorCaptured hook. A component with this hook catches all errors in its subcomponent tree (excluding itself) (excluding those called in async callbacks). If you're familiar with React, this is similar to the concept of error boundaries introduced in React 16. The hook accepts the same parameters as the global errorHandler, and you can use this hook to handle and display errors gracefully.

Better support for functional components in SFC

##Use vue-loader> = 13.3.0 and Vue 2.5, Functional components defined as single file components in *.vue files now get correct template compilation, Scoped CSS and hot reload support. This makes it easier to convert leaf components to functional for performance optimization.

*Thanks to core team member Blake Newman for his contribution to these features.

Environment-independent server-side rendering

The default build of vue-server-renderer assumes a Node.js environment, which makes it work with any JavaScript runtime ( Not available in php-v8js or Nashorn). In 2.5, we have released an environment-agnostic version of vue-server-renderer that can be used in the browser or a pure JavaScript engine. This can open up interesting strategies, such as using Vue server-side rendering directly in the PHP process.

Similarly, we recommend you check out the full release notes to learn about other API improvements, including v-on, v-model, scoped slot, provide/inject, etc. You may also be interested in our public blueprint detailing the team's work. Cheers!

Related recommendations:

Improvements related to TypeScript in Vue 2.5

##Vue.js 2.5 new feature sharing

vue.js installation tutorial graphic

The above is the detailed content of Vue 2.5 Level E new features and features shared. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn