<!DOCTYPE html>
<html>
<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>Document</title>
</head>
<body>
<div id='app'>
<!-- 2. 使用组件 赋值 -->
<com-a :a="b"></com-a>
</div>
<script src='./vue.js'></script>
<script>
Vue.component("com-a", {
template: `
<div>
我是来自父组件的数据--{{a}}
</div>
`,
// 1. 定义一个属性(变量) 此时没值
props: ["a"],
methods: {}
});
new Vue({
el: '#app',
data: {
b: "我是b"
},
methods: {
}
});
</script>
</body>
</html>
原文:https://www.cnblogs.com/divtab/p/10940917.html