cron表达式转换

安装:
npm install cronstrue --save
引入:
import cronstrue from "cronstrue/i18n";
使用:
cronstrue.toString(this.cron,{ locale: "zh_CN"})

注释:vue-cron 一周是从周日开始,所以周日是1,但是cronstrue一周是从周一开始,周一是1

cronstrue提供属性dayOfWeekStartIndexZero,默认为ture,修改为false就是从周日开始。

computed:{
        cronLabel(){
            if(this.formData.cron){
                return cronstrue.toString(this.cron,{ locale: "zh_CN",dayOfWeekStartIndexZero:false })
            }
        }
    },

 

posted @ 2025-05-30 15:54  埃菲尔上的加菲猫  阅读(66)  评论(0)    收藏  举报