您的位置:首页 > Web前端 > Vue.js

(精华)2020年7月12日 vue 模板template的使用

2020-07-14 06:00 288 查看
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>引用模板</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
<div id="app">
<my-world></my-world>
</div>

<template id="wbs">
<div>
<h3>{{msg}}</h3>
<ul>
<li v-for="(item,index) in arr" :key="index">{{item}}</li>
</ul>
</div>
</template>
<script>
var vm = new Vue({ //这里的vm也是一个组件,称为根组件Root
el: '#app',
data: {
msg: '软谋'
},
components: {
'my-world': {
name: 'wbsx',
template: '#wbs',
data() {
return {
age: '20',
msg: 'hello',
arr: ['tom', 'jack', 'laney']
}
}
}
}
});
</script>
</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: