Home  >  Article  >  Web Front-end  >  How to use template in Vue2 template

How to use template in Vue2 template

亚连
亚连Original
2018-06-05 09:42:353059browse

Below I will share with you a summary of the four writing methods of Vue2 template template. It has a good reference value and I hope it will be helpful to everyone.

is as follows:

<p id="app"> 
 <h1>我是直接写在构造器里的模板1</h1> 
</p> 
 
<template id="demo3"> 
 <h1 style="color:red">我是选项模板3</h1> 
</template> 
 
<script type="x-template" id="demo4"> 
 <h1 style="color:red">我是script标签模板4</h1> 
</script> 
 
<script> 
 var vm=new Vue({ 
  el:"#app", 
  data:{ 
   message:1 
  }, 
 
  //第2种模板 写在构造器里 
  //template:`<h1 style="color:red">我是选项模板2</h1>` 
 
  //第3种模板 写在<template>标签里 
  //template:&#39;#demo3&#39; 
 
  //第4种模板 写在<script type="x-template">标签里 
  template:&#39;#demo4&#39; 
 }) 
</script>

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

How to build element-ui (detailed tutorial)

##How to modify the default style in elementui

Use elementUI to implement custom theme methods in Vue

The above is the detailed content of How to use template in Vue2 template. 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