Vue·父子组件值传递
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
<h2>普通的css布局实现项目</h2>
<p>测试vue使用在项目中,不是整个项目用vue写的 局部使用</p>
<h3>父组件传值给子组件</h3>
<hr>
<hr>
子组件获取父组件的值
<template id="temp">
<div>
<h2>====Login====</h2>
<p>==={{ mess }}===</p>
<p>==={{ string }}===</p>
</div>
</template>
<hr>
<div id='app'>
// 绑定组件1
<login v-bind:mess="message" v-bind:string="str"></login>
</div>
</body>
<script>
const login = {
template:'#temp',
props:['mess','string']
}
const vm = new Vue({
el: '#app',
components: {
login
},
data: {
message: '我是父组件的数据',
str: '又下雨了',
arr: [1,2,3]
}
})
</script>
</html>