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 socket练习
    python异常处理
    python类的反射
    类的特殊成员方法
    staticmethod classmethod property方法
    类的多态
    类的析构、继承
    python subprocess模块
    python面向对象
    discuz 使模板中的函数不解析 正常使用
  • 原文地址:https://www.cnblogs.com/IwishIcould/p/12444918.html
Copyright © 2011-2022 走看看