Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
tswj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2022-05-26 02:20:24 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2d6ee3c1f60bfd58986835fccd15d4d1ae92c4d9
2d6ee3c1
1 parent
ba93f70f
新增全局变量创建和使用模块
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
src/hooks/injectionSymbols.js
src/hooks/useContext.js
src/hooks/injectionSymbols.js
0 → 100644
View file @
2d6ee3c
/**
* 依赖注入命名集合
*/
export
const
myInjectionKey
=
Symbol
()
export
const
fooInjectionKey
=
Symbol
()
src/hooks/useContext.js
0 → 100644
View file @
2d6ee3c
import
{
provide
,
inject
}
from
"vue"
;
// const key = Symbol();
/**
* 创建全局变量
* @param {*} context
* @param {*} key
*/
export
function
createContext
(
context
,
key
)
{
provide
(
key
,
context
)
}
/**
* 使用全局变量
* @param {*} key
* @returns
*/
export
function
useContext
(
key
)
{
return
inject
(
key
)
}
Please
register
or
login
to post a comment