1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| <!DOCTYPE html> <html lang="zh-CN">
<head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css"> <script src="https://unpkg.com/element-ui/lib/index.js"></script> <script src="https://unpkg.com/axios/dist/axios.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.30.1/moment-with-locales.min.js" integrity="sha512-4F1cxYdMiAW98oomSLaygEwmCnIP38pb4Kx70yQYqRwLVCs3DbRumfBq82T08g/4LJ/smbFGFpmeFlQgoDccgg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> </head>
<body> <div id="app"> {{ message }} </div>
<script> moment.locale('zh-CN') moment.defaultFormat = 'YYYY-MM-DD HH:mm:ss' moment.fn.toJSON = function () { return this.format() }
moment.duration.fn.format = function () { let result = [ Math.floor(this.asDays()) + '.' + Math.floor(this.hours()).toString().padStart(2, 0), Math.floor(this.minutes()).toString().padStart(2, 0), Math.floor(this.seconds()).toString().padStart(2, 0) + '.' + Math.floor(this.milliseconds()) ].join(':').replace(/0+$/, '').replace(/\.0*$/, '').replace(/^0\./, '').replace(/^00:/, '').replace(/^00:/, '').replace(/^0+/, '')
return result } moment.duration.fn.toString = moment.duration.fn.format
Vue.prototype.$console = console Vue.prototype.$moment = moment
var app = new Vue({ el: '#app', data: { message: 'Hello Vue!' } }) </script> </body>
</html>
|