2.1.0 • Published 2 years ago
vue-utility-block v2.1.0
vue-utility-block
这个工具包,旨在帮助我们在 vue 组件中更加语义化地设置阻塞变量
this utility aim to help us use block variable semantically, in vue component
Usage:
stage first:
npm i vue-utility-block --save
stage second:
import vueUtilityBlock from 'vue-utility-block'
Vue.sue(vueUtilityBlock)
Methods Introduction:
pd_defBlock(blockName:string)=> void
定义一个名为blockName
的阻塞变量(默认这个变量是非阻塞的)
define a block variable called blockName
(this variable is unblocked default)
pd_getBlock(blockName:string)=> boolean
获取这个名为blockName
阻塞变量的状态
get statue of the block variable called blockName
pd_setBlockReady(blockName:string)=> void
设置这个名为blockName
的阻塞变量为非阻塞状态
set status unblocked of the block called blockName
pd_setBlock(blockName:string)=> void
设置这个名为blockName
的阻塞变量为阻塞状态
(这个方法与上一个方法内部是相同的,旨在提供更好的语义化)
set status blocked of the block called blockName
DEMO:
export default{
data(){
//you can define it there
this.pd_setBlock('YOUR_BLOCK_NAME')
},
created(){
//or define it there
this.pd_setBlock('YOUR_BLOCK_NAME')
},
methods:{
methodA:(){
if(this.pd_getBlock('YOUR_BLOCK_NAME')){
return this.pd_setBlockReady('YOUR_BLOCK_NAME')
}
this.pd_setBlock('YOUR_BLOCK_NAME')
//if methodA called methodB will be blocked
...
},
methodB:(){
if(this.pd_getBlock('YOUR_BLOCK_NAME')){
return this.pd_setBlockReady('YOUR_BLOCK_NAME')
}
this.pd_setBlock('YOUR_BLOCK_NAME')
//if methodB called methodA will be blocked
...
},
}
}