欢迎来到博客园~~~

vue.js基础__componen props属性设置

以局部组件为例,在components中设置 props选项,挂载我们设置的属性,代码如下:

<!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>componen-2 props属性设置</title>
<script src="../assets/js/vue.js"></script>
</head>

<body>
<h1>componen-2 props属性设置</h1>
<hr>
<div id="app">
<js :here="message"></js>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
message: 'hello'
},
components: {
'js': {
template: `<div style="color:green">{{ here }}</div>`,
props: ['here']
}
}
})
</script>
</body>

</html>

 

posted @ 2019-06-28 09:41  孙~洋  阅读(411)  评论(0编辑  收藏  举报