欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【汇智学堂】-Vue.js入门之四(计算属性的使用)

程序员文章站 2022-06-06 23:19:45
...
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<div id="app">
			<h1>{{firstname}}</h1>	
			<h1>{{secondname}}</h1>
			<h1>{{fullname}}</h1>
		</div>
	</body>
		
	<script src='https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.min.js'></script>
		
		<script>
			var vm=new 	Vue({
				el:'#app',
				data:{
					firstname:'hello world,I am Vue.js',
					secondname:'good!',
					fullname2:'come and study!'
				},
				computed:{
					fullname:function(){
						return this.firstname+','+this.secondname
					}
				}
			});
		</script>	
			
</html>

相关标签: vue入门