The method is: 1. Use the original template syntax to mount rendering; 2. Use the render attribute and createElement function to render directly; 3. Use the render attribute to render with the component's template attribute and createElement function; 4. Use the render attribute to render with single-file components.
The operating environment of this article: Windows 10 system, Vue version 2.9.6, DELL G3 computer.
Personal summary of the rendering methods in Vue can be divided into 4 types:
Original template syntax, mounted rendering
Use the render attribute, and the createElement function renders directly
Use the render attribute, and match the template attribute of the component, and the createElement function renders
Use render attribute, cooperate with single file component, createElement function rendering
##Method 1:
Original template syntax , mount rendering, that is, rendering in HTML. When the page returns, the v-model and other attributes in the HTML are not rendered and are sent to the client unchanged. The client will not render these identifiers until Vue is loaded and the instance is created.Method 2:
Use the render attribute and the createElement function to render directly: there is no html originally, and the page is generated through the complete programming capabilities of JavaScript. The characteristic is that it is only suitable for rendering some details. Although the output is completely controlled, it is not intuitive enough and the implementation is complicated.Method 3:
Use the render attribute, cooperate with the template attribute of the component, and createElement function rendering. Compared with the previous method, adding components and using the template attribute is more intuitive. It also has no html and is rendered through the render function. It is characterized by dynamic rendering and module separation through components. However, the html template is wrapped in ````, which is inconvenient to use. The IDE cannot highlight the code and is not suitable for large projects.Method 4:
Use the render attribute, cooperate with the single file component, and createElement function to render. This method is the rendering method of most Vue projects (the official scaffolding uses this rendering method). If you have used vue CLI, you should be familiar with it. The characteristics are single-file components, modularity, dynamic rendering, and typical single-page applications. 【Related recommendation: "vue.js Tutorial"】
The above is the detailed content of What is the vue rendering method?. For more information, please follow other related articles on the PHP Chinese website!