73 lines
2.1 KiB
Markdown
73 lines
2.1 KiB
Markdown
|
||
<h1 align="center">
|
||
茶址
|
||
</h1>
|
||
|
||
<div align="center">
|
||
使用Unibest开发,版本号3.8.2
|
||
</div>
|
||
|
||
<div>开发规范</div>
|
||
1. 页面或组件添加方法的时候前面加上<b>handle</b>关键字,除了插件相关内容如mescroll
|
||
handleConfirmHour: () => {
|
||
if (totalHour.value <= 0) {
|
||
toast.info('至少起订N小时')
|
||
return
|
||
}
|
||
showReservePopup.value = false
|
||
},
|
||
2. 页面或组件传创建的方法需要以当前文件名称作为对象按照驼峰命名
|
||
const detail = {
|
||
handleConfirmHour: () => {
|
||
if (totalHour.value <= 0) {
|
||
toast.info('至少起订N小时')
|
||
return
|
||
}
|
||
showReservePopup.value = false
|
||
}
|
||
}
|
||
3. 页面或组件传创建的内部方法需要放在函数最下面,这种方法前面不需要加上handle
|
||
const detail = {
|
||
handleConfirmHour: () => {
|
||
if (totalHour.value <= 0) {
|
||
toast.info('至少起订N小时')
|
||
return
|
||
}
|
||
showReservePopup.value = false
|
||
},
|
||
|
||
// 格式化时间
|
||
formatDate: (timestamp: number) => {
|
||
const date = new Date(timestamp)
|
||
const year = date.getFullYear()
|
||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||
const day = String(date.getDate()).padStart(2, '0')
|
||
const hour = String(date.getHours()).padStart(2, '0')
|
||
const minute = String(date.getMinutes()).padStart(2, '0')
|
||
|
||
return `${year}-${month}-${day} ${hour}:${minute}`
|
||
}
|
||
}
|
||
4. 如果组件名称与定义的对象函数名冲突,则对象函数名后面加上s
|
||
import coupon from '@/components/coupon/coupon.vue'
|
||
const coupons = {
|
||
handleConfirmHour: () => {
|
||
if (totalHour.value <= 0) {
|
||
toast.info('至少起订N小时')
|
||
return
|
||
}
|
||
showReservePopup.value = false
|
||
},
|
||
|
||
// 格式化时间
|
||
formatDate: (timestamp: number) => {
|
||
const date = new Date(timestamp)
|
||
const year = date.getFullYear()
|
||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||
const day = String(date.getDate()).padStart(2, '0')
|
||
const hour = String(date.getHours()).padStart(2, '0')
|
||
const minute = String(date.getMinutes()).padStart(2, '0')
|
||
|
||
return `${year}-${month}-${day} ${hour}:${minute}`
|
||
}
|
||
} |