vue组件eleme 时间选择器问题
来源:互联网 发布:苹果设计软件sketch 编辑:程序博客网 时间:2024/06/05 00:33
使用饿了么vue时间选择组件时选择的时间显示为本地时间 在传递数据到后台是时间慢8小时
解决方法.tostring();
或者定义date扩展
Date.prototype.Format = function (fmt) { //author: meizz var o = { "M+": this.getMonth() + 1, //月份 "d+": this.getDate(), //日 "h+": this.getHours(), //小时 "m+": this.getMinutes(), //分 "s+": this.getSeconds(), //秒 "q+": Math.floor((this.getMonth() + 3) / 3), //季度 "S": this.getMilliseconds() //毫秒 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt;}再对时间进行格式化得到结果则为本地时区时间
另外可以对其模块化 新建dateFormat.js
export default function(fmt) { var o = { "M+": this.getMonth() + 1, //月份 "d+": this.getDate(), //日 "h+": this.getHours(), //小时 "m+": this.getMinutes(), //分 "s+": this.getSeconds(), //秒 "q+": Math.floor((this.getMonth() + 3) / 3), //季度 "S": this.getMilliseconds() //毫秒 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt;}引入模块
import DateFormat from "../dateFormat.js"; //日期格式化扩展导入Date.prototype.Format = DateFormat; //日期格式化扩展加载
default关键字
别名的语法糖:
// d.jsexport default function() {}// 等效于:function a() {};export {a as default};
在import的时候,可以这样用:
import a from './d';// 等效于,或者说就是下面这种写法的简写,是同一个意思import {default as a} from './d';
阅读全文
4 0
- vue组件eleme 时间选择器问题
- vue组件命名问题
- vue.js 组件问题
- Vue 2.0 实战之仿Eleme WebApp SPA(学习)
- 安卓界面组件----时间日期选择器
- vue日期选择器自定义时间校验-使用element-ui实现
- 日期时间选择器 Bootstrap日期和时间表单组件。
- 解决vue不相关组件之前数据传输问题
- vue子组件向父组件传值问题
- table边框颜色被覆盖还有一款vue时间组件
- React Native开源时间日期选择器组件
- 封装一个实用的日期时间选择器,时钟组件
- Date & Time组件(下)-TimePicker(时间选择器)
- vue 组件
- Vue组件
- vue 组件
- vue组件
- Vue组件
- Slam资源转载
- MongoDB--MapReduce分布统计s
- 对庄重有所把持
- java高阶与数据库小结
- window.onload与jQuery的ready的区别
- vue组件eleme 时间选择器问题
- F1V3.0-3 前端开发问题之解决之道
- Java初级第三天
- SOUI中使用SSendMessage
- Android开发中常用的工具整理
- 'objc_unretainedObject' is unavailable:use a (__bridge id) cast instead
- MyBatis学习(一)之一对一关联映射查询
- 类、构造方法方法的调用对象创建实例(1)
- 解决IDEA开发JavaWeb项目修改了HTML或Servlet/JSP后刷新浏览器无法及时显示修改后的页面的问题