1.日期格式化
安装插件,官网:Moment.js
npm install moment --save
示例:
//Sat Mar 14 2020 16:57:59 GMT+0800 (中国标准时间)
let date = new Date();
//2020-03-14 16:57:59
date = moment(date).format("YYYY-MM-DD HH:mm:ss");
2.引用JSON文件中的数据
import ChineCitys from '../../../static/ChineCitys.json'
console.log(ChineCitys)
3.elementUI 点击图片跳转后,滚动条不见了
<router-link :to="{path:'/detail',query: {bookId: book.id}}">
<el-image :src="book.images[0].path"></el-image>
</router-link>
这是一个Bug
body
被加上了一个style="overflow: hidden;
原因就是页面跳转后,解决方法:
- 第一种:为body设置属性
overflow: auto !important;
- 第二种:用路由设置属性
router.afterEach((to, from, next) => {
document.querySelector("body").setAttribute("style", "overflow: auto !important;")
});
- 第三种:不要用
<el-image>
标签,用原生或其他框架的