In-depth study of vue2.x--Explanation of the h function

In-depth study of vue2.x--Explanation of the h function

vue project. The code written in the template of the .vue file needs to be parsed with the help of the webpack template parser plug-in. When a single .html file introduces a vue file, the vue file also introduces the template parser (the disadvantage is that it is large in size).

Therefore, when we use engineering development projects, we need to introduce vue-template-compile in the package.json file for template parsing.

insert image description here

If there is no template parser, it cannot be parsed, but vue-template-compile can only parse templates in .vue files, and cannot parse templates in .js files:

So when we write this, it won't work.

insert image description here

insert image description here

Why can't it be parsed? Because the vue file introduced by the main.js file does not have a template parser

insert image description here

insert image description here

vue.runtime.common.js is a .vue file without a template parser, and vue.js is a vue file with a template parser

insert image description here

If we import the vue.js file with the template parser in main.js, we can parse the template

insert image description here

insert image description here

Why is the vue.js file without template parser imported by default?
Because of the volume issue:

insert image description here

Solution,

Use the official render function. He can call the introduced vue-template-compile through the h function, that is, the ninth line of code is equivalent to the eleventh and twelfth lines plus the loader template parser.

insert image description here

Summarize:

insert image description here

This article ends here. I hope it can be helpful to you. I also hope that you can pay more attention to more content on 123WORDPRESS.COM!

You may also be interested in:
  • Detailed explanation of how to use $props, $attrs and $listeners in Vue

<<:  Implementation of remote Linux development using vscode

>>:  MySQL derived table (Derived Table) simple usage example analysis

Recommend

Detailed explanation of Docker basic network configuration

External Access Randomly map ports Using the -P f...

Solution to invalid Nginx cross-domain setting Access-Control-Allow-Origin

nginx version 1.11.3 Using the following configur...

Detailed explanation of Vue configuration request multiple server solutions

1. Solution 1.1 Describing the interface context-...

MySQL 5.7.17 winx64 installation and configuration tutorial

Today I installed the MySQL database on my comput...

MySQL uses SQL statements to modify table names

In MySQL, you can use the SQL statement rename ta...

Example analysis of the use of GROUP_CONCAT in MySQL

This article uses an example to describe how to u...

Use auto.js to realize the automatic daily check-in function

Use auto.js to automate daily check-in Due to the...

Negative distance (empathy) - iterative process of mutual influence

Negative distance refers to empathy. Preface (rai...

MySQL 5.7.17 installation and configuration tutorial under CentOS6.9

CentOS6.9 installs Mysql5.7 for your reference, t...

VMware Workstation installation Linux system

From getting started to becoming a novice, the Li...

Vue2.x configures routing navigation guards to implement user login and exit

Table of contents Preface 1. Configure routing na...

How to build pptpd service in Alibaba Cloud Ubuntu 16.04

1. To build a PPTP VPN, you need to open port 172...

How to implement paging query in MySQL

SQL paging query:background In the company's ...

Learn asynchronous programming in nodejs in one article

Table of Contents Introduction Synchronous Asynch...