vue数据交互一
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>父传子数据传递</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
<script src="vue/vue.js"></script>
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div id="app">
<div>{{msg}}</div>
<!-- 以:属性绑定的形式实现动态的将父组件数据给子组件,父组件属性值更改,子组件获得的值一起更改 -->
<hellow-tom :title="title"></hellow-tom>
<!--直接赋值的静态数据交互 -->
<hellow-tom title="我是父组件数据"></hellow-tom>
</div>
<script>
Vue.component('hellow-tom',{
props:['title'],
data:function() {
return{
msh:'我是全局子组件数据',
}
},
template:'<div>{{msh + "---" + title}}</div>'
})
var vm = new Vue({
el:'#app',
data:{
msg:'我是父组件,也是实例,标签就是模板',
title:'我是父组件数据',
},
});
</script>
</body>
</html>