Vue2 模板template的四种写法总结
作者:xuanwuziyou 时间:2023-07-02 16:50:18
如下所示:
<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
标签:vue,template
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python中时间模块的基本使用教程
2021-05-15 21:24:43
ASP 高亮显示不区分大小写的关键字
2011-03-09 10:45:00
python采集天气数据并做数据可视化
2022-07-16 15:26:39
![](https://img.aspxhome.com/file/2023/7/85047_0s.jpg)
uniapp实现人脸识别功能的具体实现代码
2024-04-17 09:57:36
Django零基础入门之运行Django版的hello world
2022-11-10 02:44:58
![](https://img.aspxhome.com/file/2023/1/69611_0s.jpg)
JavaScript中callee和caller的区别与用法实例分析
2024-04-10 13:59:35
![](https://img.aspxhome.com/file/2023/0/136860_0s.png)
python实现求两个字符串的最长公共子串方法
2021-08-02 21:14:08
![](https://img.aspxhome.com/file/2023/9/128639_0s.jpg)
JavaScript开发人员的10个关键习惯小结
2024-04-18 09:51:09
ThinkPHP开发框架函数详解:C方法
2023-10-18 03:27:04
简单的Apache+FastCGI+Django配置指南
2021-01-27 10:09:16
当面试官问mysql中char与varchar的区别
2024-01-15 12:36:01
![](https://img.aspxhome.com/file/2023/8/82258_0s.png)
php中对象引用和复制实例分析
2023-10-20 23:05:02
MySQL存储过程例子(包含事务,输出参数,嵌套调用)
2024-01-17 06:21:54
SQL SERVER如何判断某个字段包含大写字母
2023-07-01 21:19:12
Python函数之zip函数的介绍与实际应用
2022-06-02 00:52:51
![](https://img.aspxhome.com/file/2023/7/103267_0s.png)
Python Pandas教程之series 上的转换操作
2023-08-16 22:20:50
![](https://img.aspxhome.com/file/2023/4/109494_0s.png)
python+Word2Vec实现中文聊天机器人的示例代码
2023-08-04 13:11:29
JQUERY新手学习笔记
2008-09-28 12:43:00
Pytorch BertModel的使用说明
2023-06-28 09:30:37
AES算法 asp源码
2009-08-28 13:05:00