<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<script type="text/javascript" src="js/vue.js"></script>
		<title></title>
	</head>
	<body>
    <h1>component-1</h1>
    <hr>
    <div id="app">
		<panda></panda>
    </div>
    <script type="text/javascript">
    	//子组件
    	var city={
    		template:`<div style="color:green;">sichuan of china</div>`
    	}
    	//父组件   --父组件引用子组件
    	var pandaCpmponent = {
    		template:`
    		<div>
    			<p style="color:red;">Panda from china</p>
    			<city></city>
    		</div>
    		`,
    		components:{
    			"city":city
    		}
    	}
        var app=new Vue({
            el:'#app',
            components:{
            	"panda":pandaCpmponent
            },
            data:{
            	message:'china'
            },
        })
    </script>
</body>
</html>

 

Logo

前往低代码交流专区

更多推荐