<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Template</title>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/vue.js" ></script>
</head>
<body>
<h1>Template三种写法</h1>
<hr>
<div id="app">
{{ message }}
</div>
<template id="dd2">
<h2 style="color:red">我是Template标签模板</h2>
</template>
<!-- 下面是是第三种写法: 好处:可以进行外部引用-->
<script type="x-template" id="dd3" src="">
<h2 style="color:red">我是Script标签模板</h2>
</script>
<script type="text/javascript">
var app = new Vue({
el : '#app',
data : {
message:'hello world'
},
//第一种写法:适用于很小的模板
// template:`
// <h2 style="color:red">我是选项模板</h2>
// `
//第二种写法:需要在html中增加template标签
// template:"#dd2"
//第三种写法在这里加上:
template:"#dd3"
})
</script>
</body>
</html>
VUE学习之路(二)----全局API之Template 制作模版
猜你喜欢
转载自blog.csdn.net/ferrysoul/article/details/81432163
今日推荐
周排行