首页 > 其他 > 详细

组件的使用

时间:2020-07-22 23:15:47      阅读:58      评论:0      收藏:0      [点我收藏+]

app.js

// 组件
Vue.component("greeting",{
	template:`<p>{{name}}大家好,给大家介绍一下我的女朋友@关晓彤
	<button v-on:click="changeName">点击我变化</button></p>
	`,
	data:function(){
		return{
			name:"鹿晗"
		}
	},
	methods:{
		changeName:function(){
				this.name="Herry";
				console.log(123)
			}
		}
})


// 对象
new Vue({
	el:"#ttt",
	data:{
		color:"red",
		dis:true
	}
});

 

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <title>lucax测试</title>
<link rel="stylesheet" href="style.css">        
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>    
</head>
<body>


<div id="ttt">
<!-- #使用组键 -->
<greeting></greeting>
</div>


<script src="app.js"></script>
</body>
</html>

 

 

效果

技术分享图片

 

组件的使用

原文:https://www.cnblogs.com/kaibindirver/p/13363281.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!