Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
liyeyun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cfld-frontend
liyeyun
Commits
38b23927
Commit
38b23927
authored
Nov 22, 2023
by
王玉鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 省市区hook
parent
d110ff6a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
1 deletion
+43
-1
useCity.ts
src/composable/useCity.ts
+42
-0
cities.json
src/utils/cities.json
+0
-0
tsconfig.app.json
tsconfig.app.json
+1
-1
No files found.
src/composable/useCity.ts
0 → 100644
View file @
38b23927
import
cityData
from
'@/utils/cities.json'
;
import
{
computed
,
ref
}
from
'vue'
;
export
interface
CityData
{
value
:
string
;
name
:
string
;
parent
?:
string
;
children
?:
CityData
[];
}
/**
* 省市区数据
*/
export
function
useAddress
()
{
const
cityList
:
CityData
[]
=
cityData
;
const
currentProvince
=
ref
<
CityData
|
null
>
(
null
);
const
currentCity
=
ref
<
CityData
|
null
>
(
null
);
const
currentRegion
=
ref
<
CityData
|
null
>
(
null
);
/**
* 当前省的市列表
*/
const
currentCityList
=
computed
(()
=>
{
return
currentProvince
.
value
?.
children
||
[];
});
/**
* 当前市的区列表
*/
const
currentRegionList
=
computed
(()
=>
{
return
currentCity
.
value
?.
children
||
[];
});
return
{
cityList
,
currentProvince
,
currentCity
,
currentRegion
,
currentCityList
,
currentRegionList
,
};
}
src/utils/cities.json
0 → 100644
View file @
38b23927
This diff is collapsed.
Click to expand it.
tsconfig.app.json
View file @
38b23927
{
"extends"
:
"@vue/tsconfig/tsconfig.dom.json"
,
"include"
:
[
"env.d.ts"
,
"src/**/*"
,
"src/**/*.vue"
],
"include"
:
[
"env.d.ts"
,
"src/**/*"
,
"src/**/*.vue"
,
"src/**/*.json"
],
"exclude"
:
[
"src/**/__tests__/*"
],
"compilerOptions"
:
{
"composite"
:
true
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment