网络编程
位置:首页>> 网络编程>> JavaScript>> Vue2 模板template的四种写法总结

Vue2 模板template的四种写法总结

作者:xuanwuziyou  发布时间:2023-07-02 16:50:18 

标签:vue,template

如下所示:


<div id="app">
<h1>我是直接写在构造器里的模板1</h1>
</div>

<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:'#demo3'

//第4种模板 写在<script type="x-template">标签里
 template:'#demo4'
})
</script>

推荐第4种。

来源:http://blog.csdn.net/xuanwuziyou/article/details/77930803

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com