<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<div>{{date|format('yyyy-MM-dd')}}</div>
</div>
<script type="text/javascript" src="./js/vue.js"></script>
<script>
/* 侦听器 监听用户变化*/
/* Vue.filter('upper', function(val) {
return val.charAt(0).toUpperCase() + val.slice(1);
}); */
Vue.filter('format', function(value, arg) {
//console.log(arg);
if (arg == 'yyyy-MM-dd') {
var ret = '';
ret += value.getFullYear() + '-' + (value.getMonth() + 1) + '-' + value.getDate();
return ret;
}
return value;
})
var vm = new Vue({
el: '#app',
data: {
date: new Date()
},
})
</script>
</body>
</html>