11_过滤器_1
作者:互联网
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>过滤器practice</title>
</head>
<body>
<div id="demo">
<p>{{ time }}</p>
<p>{{ time | dateString }}</p>
<p>{{ time | dateString('YYYY-MM-DD HH:mm:ss') }}</p>
</div>
<script type="text/javascript" src="../js/vue.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/moment.js/2.29.1/moment.js"></script>
<script type="text/javascript">
Vue.filter('dateString',function (value,format='MMMM Do YYYY, h:mm:ss a') {
return moment(value).format(format);
});
new Vue({
el: '#demo',
data: {
time:new Date()
},
mounted(){
this.intervalId=setInterval(()=>{
this.time=new Date();
},1);
},
beforeDestroy(){
clearInterval(this.intervalId);
}
});
</script>
</body>
</html>
标签:11,format,dateString,intervalId,Date,time,过滤器,new 来源: https://blog.csdn.net/weixin_47952737/article/details/120601041