分享

成功el-table格式化日期

 北方天空A 2021-04-09

main.js文件中
import Vue from 'vue'
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/styles/index.scss' // global css
import App from './App'
import store from './store'
import router from './router'
import Moment from 'moment';
import '@/icons' // icon
import '@/permission' // permission control
import "@/styles/Common.scss";
import global_ from '@/components/Global';//引用文件
import CommonJs from "@/utils/Common.js";
if (process.env.NODE_ENV === 'production') {
  const { mockXHR } = require('../mock')
  mockXHR()
}
Vue.prototype.GLOBAL = global_;//挂载到Vue实例上面
Vue.prototype.moment = Moment;//引用时间控件
Vue.prototype.CommonJs = CommonJs;//引用公共js文件
Vue.use(ElementUI);

Vue.config.productionTip = false
Vue.filter('dateYMDFormat',function(dateStr,pattern='YYYY-MM-DD'){
  return Moment(dateStr).format(pattern);
})
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
页面中
 <el-table-column prop="TreatmentTime" label="治疗时间" align="center">
          <template slot-scope="scope">
            {{ scope.row.TreatmentTime | dateYMDFormat }}
          </template>
        </el-table-column>

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约