vue2.x搭建saas项目系列之九:utils、directives、filters、types

此篇幅主要介绍、我们是如何全局管理及使用工具类相关,如有不足和建议请留言,在此感谢,项目目前阶段还处在少年,一直在迭代

一. utils

// 注册 自定义工具函数
import * as ompUtils from '@/utils/utils'
// Register global utils functions
Vue.prototype.$ompUtils = ompUtils 
declare module 'vue/types/vue' {
  interface Vue {
    $ompUtils: any
  }
}

// 使用
this.$fmOmpUtils.getSessionStorage('')

二. directives

// Register global directives
import * as directives from '@/directives'

Object.keys(directives).forEach((key) => {
  Vue.directive(key, (directives as { [key: string ]: DirectiveOptions })[key])
})

// 使用
<el-button
  v-clipboard:copy="https://"
  v-clipboard:success="clipboardSuccess"
  type="primary">
  复制链接
</el-button>

三.filters

// Register global filter functions
import * as filters from '@/filters'

Object.keys(filters).forEach((key) => {
  Vue.filter(key, (filters as { [key: string ]: Function })[key])
})

// 使用
<omp-switch
  @change="switchChange"
  switchClass="open-class"
  :switchState="formModel.state | isAvailableStateFilter">
</omp-switch>

四. types

 

到此,utils、directives、filters、types-文章结束,原创不易,感谢浏览!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值