最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue3中定時任務(wù)cron表達(dá)式組件的比較分析

 更新時間:2025年10月25日 15:14:18   作者:Qredsun  
文章比較了三種適用于Vue3的cron組件:vue3-cron-plus、no-vue3-cron和vue3-cron-plus-picker,每種組件的安裝和使用實例都詳細(xì)列出,最終對比發(fā)現(xiàn),vue3-cron-plus-picker不僅可以從組件中獲取cron表達(dá)式,還能顯示任務(wù)的執(zhí)行時間,因此推薦使用

背景

之前使用vue2開發(fā)項目時,使用了cron組件,比較了兩種組件的使用效果。

現(xiàn)在需要把原有的vue2項目升級為vue3,需要對應(yīng)的cron組件。

方案一、vue3-cron-plus

具體實現(xiàn):

安裝插件

npm install vue3-cron-plus -S

vue文件使用實例:

<template>
		<div>
    <el-input class="elInput" v-model="cronValue"  @click="openDialog" :clearable="true"  placeholder="請輸入正確的cron表達(dá)式">
    </el-input>
    <el-dialog v-model="showCron">
				<vue3CronPlus
					@change="changeCron"
					@close="closeDialog"
					max-height="600px"
					i18n="cn">
				</vue3CronPlus>
		</el-dialog>
  </div>
</template>

<script>
import { vue3CronPlus } from 'vue3-cron-plus'
import 'vue3-cron-plus/dist/index.css' // 引入樣式
export default {
	name : "DemoCompare",
	components: { "vue3CronPlus":vue3CronPlus },
	data () {
		return{
			cronValue:"",
			showCron:"",
		}
	},
	methods : {
		openDialog () {
			this.showCron = true;
		},
		closeDialog(){
			this.showCron = false;
		},
		changeCron(cronValue){
			if (typeof (cronValue) == "string") {
				this.cronValue = cronValue;
			}
		}
	}
}
</script>

<style scoped>

</style>

方案二、no-vue3-cron

具體實現(xiàn):

安裝插件

npm install no-vue3-cron -S

vue文件使用實例:

<template>
		<div>
    <el-input class="elInput" v-model="cronValue"  @click="openDialog" :clearable="true"  placeholder="請輸入正確的cron表達(dá)式">
    </el-input>
    <el-dialog v-model="showCron">
				<noVue3Cron
					:cron-value="cronValue"
					@change="changeCron"
					@close="closeDialog"
					max-height="600px"
					i18n="cn">
				</noVue3Cron>
		</el-dialog>
  </div>
</template>

<script>
//局部引入
import { noVue3Cron } from 'no-vue3-cron'
import 'no-vue3-cron/lib/noVue3Cron.css' // 引入樣式
export default {
	name : "DemoCompareShow",
	components: { "noVue3Cron":noVue3Cron },
	data () {
		return{
			cronValue:"",
			showCron:"",
			expression:"* * * * * * *"
		}
	},
	methods : {
		openDialog () {
			this.showCron = true;
			if (this.cronValue != "") {
				this.expression = this.cronValue
			}
		},
		closeDialog(){
			this.showCron = false;
		},
		changeCron(cronValue){
			if (typeof (cronValue) == "string") {
				this.cronValue = cronValue;
			}
		}
	}
}
</script>

<style scoped>

</style>

方案三、vue3-cron-plus-picker

具體實現(xiàn):

安裝插件

npm install vue3-cron-plus-picker -S

vue文件使用實例:

<template>
	<div>
    <el-input class="elInput" v-model="cronValue"  @click="openDialog" :clearable="true"  placeholder="請輸入正確的cron表達(dá)式">
    </el-input>
    <el-dialog v-model="showCron">
      <Vue3CronPlusPicker @hide="closeDialog" @fill="fillValue" :expression="expression"/>
    </el-dialog>
  </div>
</template>

<script >
import 'vue3-cron-plus-picker/style.css'
import {Vue3CronPlusPicker} from 'vue3-cron-plus-picker'

export  default {
	name : "demoShow",
	components : {"Vue3CronPlusPicker":Vue3CronPlusPicker,},
	data () {
		return{
			cronValue:"",
			showCron:"",
			expression:"* * * * * * *"
		}
	},
	methods : {
		openDialog () {
			this.showCron = true;
			if (this.cronValue != ""){
				this.expression = this.cronValue
			}
		},
		closeDialog(){
			this.showCron = false;
		},
		fillValue(cronValue){
			this.cronValue = cronValue;
		}
	}
}
</script>

<style lang="scss" scoped>
</style>

對比

  1. 都可以從組件中獲取cron的表達(dá)式
  2. vue3-cron-plus組件不能根據(jù)cron表達(dá)式回顯到組件
  3. vue3-cron-plus-picker 組件可以看到將來執(zhí)行任務(wù)的具體時間,推薦使用

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 如何使用fetchEventSource實現(xiàn)sse流式請求

    如何使用fetchEventSource實現(xiàn)sse流式請求

    這篇文章主要介紹了如何使用fetchEventSource實現(xiàn)sse流式請求問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • vue項目中使用eslint+prettier規(guī)范與檢查代碼的方法

    vue項目中使用eslint+prettier規(guī)范與檢查代碼的方法

    這篇文章主要介紹了vue項目中使用eslint+prettier規(guī)范與檢查代碼的方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-01-01
  • 基于Vue技術(shù)實現(xiàn)遞歸組件的方法

    基于Vue技術(shù)實現(xiàn)遞歸組件的方法

    這篇文章主要為大家詳細(xì)介紹了基于Vue技術(shù)實現(xiàn)遞歸組件的方法 ,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • vue多次打包后出現(xiàn)瀏覽器緩存的問題及解決

    vue多次打包后出現(xiàn)瀏覽器緩存的問題及解決

    這篇文章主要介紹了vue多次打包后出現(xiàn)瀏覽器緩存的問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-08-08
  • Vue數(shù)據(jù)劫持詳情介紹

    Vue數(shù)據(jù)劫持詳情介紹

    這篇文章主要介紹了Vue數(shù)據(jù)劫持詳情介紹,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,感興趣的小伙伴可以參考一下,希望對你的學(xué)習(xí)有所幫助
    2022-08-08
  • 非Vuex實現(xiàn)的登錄狀態(tài)判斷封裝實例代碼

    非Vuex實現(xiàn)的登錄狀態(tài)判斷封裝實例代碼

    這篇文章主要給大家介紹了關(guān)于非Vuex實現(xiàn)的登錄狀態(tài)判斷封裝的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2022-02-02
  • Vue實現(xiàn)鼠標(biāo)懸浮切換圖片src

    Vue實現(xiàn)鼠標(biāo)懸浮切換圖片src

    這篇文章主要為大家詳細(xì)介紹了Vue實現(xiàn)鼠標(biāo)懸浮切換圖片src,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • 使用vuex解決刷新頁面state數(shù)據(jù)消失的問題記錄

    使用vuex解決刷新頁面state數(shù)據(jù)消失的問題記錄

    這篇文章主要介紹了使用vuex解決刷新頁面state數(shù)據(jù)消失的問題記錄,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • 關(guān)于vue3編寫掛載DOM的插件問題

    關(guān)于vue3編寫掛載DOM的插件問題

    這篇文章主要介紹了vue3編寫掛載DOM的插件的問題,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-07-07
  • vue二次封裝一個高頻可復(fù)用組件的全過程

    vue二次封裝一個高頻可復(fù)用組件的全過程

    在開發(fā)Vue項目我們一般使用第三方UI組件庫進(jìn)行開發(fā),但是這些組件提供的接口并不一定滿足我們的需求,這時我們可以通過對組件庫組件的二次封裝,來滿足我們特殊的需求,這篇文章主要給大家介紹了關(guān)于vue二次封裝一個高頻可復(fù)用組件的相關(guān)資料,需要的朋友可以參考下
    2022-10-10

最新評論

沙田区| 景谷| 山东| 芜湖县| 诏安县| 双柏县| 台北县| 印江| 古交市| 南召县| 台南县| 巴塘县| 云龙县| 陕西省| 和平县| 财经| 万安县| 建瓯市| 龙游县| 敖汉旗| 湟中县| 德令哈市| 嵊泗县| 永和县| 溆浦县| 牙克石市| 基隆市| 万宁市| 海丰县| 北京市| 喀喇沁旗| 饶平县| 蚌埠市| 吴忠市| 虎林市| 普安县| 温泉县| 儋州市| 墨玉县| 西昌市| 日喀则市|