当前位置:   article > 正文

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

$fmomputils

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

一. utils

  1. // 注册 自定义工具函数
  2. import * as ompUtils from '@/utils/utils'
  3. // Register global utils functions
  4. Vue.prototype.$ompUtils = ompUtils
  5. declare module 'vue/types/vue' {
  6. interface Vue {
  7. $ompUtils: any
  8. }
  9. }
  10. // 使用
  11. this.$fmOmpUtils.getSessionStorage('')

二. directives

  1. // Register global directives
  2. import * as directives from '@/directives'
  3. Object.keys(directives).forEach((key) => {
  4. Vue.directive(key, (directives as { [key: string ]: DirectiveOptions })[key])
  5. })
  6. // 使用
  7. <el-button
  8. v-clipboard:copy="https://"
  9. v-clipboard:success="clipboardSuccess"
  10. type="primary">
  11. 复制链接
  12. </el-button>

三.filters

  1. // Register global filter functions
  2. import * as filters from '@/filters'
  3. Object.keys(filters).forEach((key) => {
  4. Vue.filter(key, (filters as { [key: string ]: Function })[key])
  5. })
  6. // 使用
  7. <omp-switch
  8. @change="switchChange"
  9. switchClass="open-class"
  10. :switchState="formModel.state | isAvailableStateFilter">
  11. </omp-switch>

四. types

 

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/爱喝兽奶帝天荒/article/detail/753252
推荐阅读
相关标签
  

闽ICP备14008679号