Skip to content

Instantly share code, notes, and snippets.

@HydrangeaPurple
Created March 21, 2024 07:29
Show Gist options
  • Save HydrangeaPurple/a970b1b318e83172d43a877ed630a49c to your computer and use it in GitHub Desktop.
Save HydrangeaPurple/a970b1b318e83172d43a877ed630a49c to your computer and use it in GitHub Desktop.
[vue全局属性不报错] 让vue的全局属性在vscode中正常提示 #vue #globalProperties
import * as orderService from "./order.service"; //研发新增业务类公用方法文件 add by shenlm 2023-3-13 09:38:07
import serviceUrl from "./service.url"; //研发新增业务类公用方法文件 add by shenlm 2023-3-13 09:38:07
import tools from "./tools"; //研发新增工具类公用方法文件 add by shenlm 2023-3-13 09:38:07
import bussAcceptUtil from "./bussAcceptUtil.service"; //研发新增业务类公用方法文件 add by caoqq 2023-09-16
import codes from "./codes"; //研发新增业务类公用方法文件 add by caoqq 2023-09-16
import * as comService from "./com.service"; //研发新增业务类公用方法文件 add by caoqq 2023-09-16
import * as cpcpService from "./cpcp.service"; //研发新增业务类公用方法文件 add by caoqq 2023-09-16
import * as ruleService from "./rule.service"; //研发新增业务类公用方法文件 add by caoqq 2023-09-16
import * as resourceService from "./resource.service"; //研发新增业务类公用方法文件 add by caoqq 2023-09-16
import * as portalService from "./portal.service"; //研发新增业务类公用方法文件 add by caoqq 2023-09-16
import donMessage from "./don.message";//新增弹出信息公共方法文件 add by caoqq 2023-09-25
export default (app: any) => {
app.config.globalProperties.$bssaUtil = bussAcceptUtil;
app.config.globalProperties.$tools = tools; //研发新增工具类公用方法文件 add by shenlm 2023-3-13 09:38:07
app.config.globalProperties.$orderService = orderService; //示例,后期需要删除
app.config.globalProperties.$serviceUrl = serviceUrl;//示例,后期需要删除
app.config.globalProperties.$comService = comService;
app.config.globalProperties.$cpcpService = cpcpService;
app.config.globalProperties.$codes = codes;
app.config.globalProperties.$ruleService = ruleService;
app.config.globalProperties.$resourceService = resourceService;
app.config.globalProperties.$donMessage = donMessage;
app.config.globalProperties.$portalService = portalService;
}
// 这个的目的是注册类型, 可以在编辑器中跳转方法, 也有自动提示
// 当然 tsconfig 中要开启 strict 模式
declare module '@vue/runtime-core' {
export interface ComponentCustomProperties {
$bssaUtil: typeof bussAcceptUtil;
$tools: typeof tools;
$orderService: typeof orderService;
$serviceUrl: typeof serviceUrl;//示例,后期需要删除
$comService: typeof comService;
$cpcpService: typeof cpcpService;
$codes: typeof codes;
$ruleService: typeof ruleService;
$resourceService: typeof resourceService;
$donMessage: typeof donMessage;
$portalService: typeof portalService;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment