Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Commit 61cdab4

Browse files
committed
backup.
1 parent 09588a3 commit 61cdab4

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.0.0",
44
"description": "A data collection tool that supports reporting of single-page application data built by Vue-cli, based on cnzz statistics.",
55
"main": "dist/vue-cnzz-analytics.min.js",
6+
"types": "vue-cnzz-analytics.d.ts",
67
"scripts": {
78
"build": "rollup -c rollup.config.ts"
89
},
@@ -15,6 +16,9 @@
1516
"vue cnzz",
1617
"vue umeng",
1718
"vue analytics",
19+
"vue 3.0 cnzz",
20+
"vue 3.0 umeng",
21+
"vue 3.0 analytics",
1822
"spa analytics",
1923
"cnzz统计",
2024
"umeng统计",

src/global.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ declare global {
1414
interface Vue {
1515
prototype: any
1616
$pushCNZZ: PushCNZZ
17+
version: number | string
18+
config: any
1719
}
1820

1921
interface To {

src/modules/getVueVersion.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* 获取Vue的版本
3+
* @return 2=Vue2.x, 3=Vue3.x
4+
*/
5+
const getVueVersion = (Vue: Vue): number => {
6+
let version: number = 2;
7+
8+
// 获取Vue的版本号
9+
const VUE_VERSION: string = String(Vue.version);
10+
11+
// Vue 2.x
12+
if ( VUE_VERSION.slice(0, 2) === '2.' ) {
13+
version = 2;
14+
}
15+
16+
// Vue 3.x
17+
if ( VUE_VERSION.slice(0, 2) === '3.' ) {
18+
version = 3;
19+
}
20+
21+
return version;
22+
}
23+
24+
export default getVueVersion;

0 commit comments

Comments
 (0)