1.由父组件 传值 到子组件:(通过属性传值)
一共有7中定义component的方法,参考地址:https://medium.com/js-dojo/7-ways-to-define-a-component-template-in-vuejs-c04e0c72900d
(1)创建子组件 指定属性,把要传递的值给属性
<son name="值"></son>
(2)在子组件内部声明props属性
props:['name']
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue template</title>
<script src="../js/vue.js"></script>
</head>
<body>
<div id="example">
{
{myValue}}
<father></father>
</div>
<script type="text/x-template" id="father-template">
<div>
<h1>this is a father template component</h1>
<input type="text" v-model="kw">
<button @click="handleClick">clickMe</button>
<hr/>
<!--用 v-bind接收变化的值-->
<son :name="kw"></son>
</div>
</script>
<script type="text/x-template" id="son-template">
<div>
<h1>this is a son component</h1&