vue 全局 js 方法

Posted 漫步CODE人生

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vue 全局 js 方法相关的知识,希望对你有一定的参考价值。

1、新增 getCurrentDataType.js 文件

 

import cookieUtils from ‘@/config/cookieUtils‘

function getCurrentDataType () {
  let type = cookieUtils.get(‘curr_sjjc_data_type‘)
  if (type === ‘0‘ || type === ‘1‘) {
    return type
  }
  return ‘0‘
}

export { getCurrentDataType }

 

 

2. 在main.js 中设置

 

import { getCurrentDataType } from ‘@/utils/getCurrentDataType.js‘

.
.
.
.
.
.

Vue.prototype.$getCurrentDataType = getCurrentDataType

 

以上是关于vue 全局 js 方法的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段11——vue路由的配置

VSCode自定义代码片段11——vue路由的配置

VSCode自定义代码片段11——vue路由的配置

VSCode自定义代码片段2——.vue文件的模板

VSCode自定义代码片段13——Vue的状态大管家