0%

快速编写一个 ele vue h5 页面

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>
<!-- 引入axios -->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<!-- moment -->
<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()
}

/**
* 格式化为字符串
* @returns 序列化后的字符串, 如 1.2:3:4:55, 表示 1天 2小时 3分 4秒 550 毫秒
*/
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>