zoukankan      html  css  js  c++  java
  • 插件时间格式处理moment如何使用

    第1步下载插件 cnpm i moment -S

    第2步 在main.js中去使用

    在main.js中 注册全局过滤器 fmtdata是等会你用的 可以自定义
    fmtdata直接可以调用。是一个过滤器哈
    
    Vue.filter("fmtdata",(v)=>{
      return moment(v).format("YYYY-MM-DD")
    })
    
    
    template要使用内部的数据  设置slot-scope属性
    
    slot-scope的值tableData其实就是el-table绑定的数据tableData
    
    userlist.row是数组中的每一个对象
    

    users.vue文件####

     <el-table :data="tableData" style=" 100%">
          <el-table-column  label="创建时间">
            //fmtdata 直接嗲用过滤器,进行时间格式
            <template slot-scope="tableData">{{ tableData.row.create_time|fmtdata }}</template>
          </el-table-column>
    
           <el-table-column prop="name" label="姓名" width="180"></el-table-column>
    
    </el-table>
    
    
    注意tableData是:data="tableData"绑定的额  slot-scope="tableData"  create_time是字段  fmtdata你全局注册的过滤器
    删除 prop=""属性
    
  • 相关阅读:
    Python基本数据类型
    Python内存相关
    Python运算符和编码
    js比较日期大小 判断日期
    js判断一个数是不是正整数
    sql查询排序
    js获取select标签选中的值
    PL/sql配置相关
    搜狗的好玩用法
    Oracle数据库中的dual表
  • 原文地址:https://www.cnblogs.com/IwishIcould/p/12444918.html
Copyright © 2011-2022 走看看