使用vue 在网页上点击显示日期
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script type="text/javascript" src="../js/vue.js" ></script>
<div id='app'>
<button type="button" @click="show()">单击输出当前的日期信息(年/月/日)</button>
<p>{{date}}</p>
</div>
<script type="text/javascript">
var app = new Vue({
el:'#app',
data:{
date:'',
},
methods:{
show:function(){
var now = new Date();
var year1 = now.getFullYear();
var month = now.getMonth()+1;
var day = now.getDate();
this.date = year1+"/"+month+"/"+day
}
}
})
</script>
</body>
</html>