Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mould-vuecli3
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
lhfe
mould-vuecli3
Commits
4ebf41b7
Commit
4ebf41b7
authored
Aug 30, 2020
by
lipengcheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 组件没有name属性报错
parent
bf4b07e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
index.js
src/components/global/index.js
+5
-1
index.js
src/components/layout/index.js
+5
-1
No files found.
src/components/global/index.js
View file @
4ebf41b7
...
...
@@ -5,7 +5,11 @@ requireContext
.
filter
((
path
)
=>
path
!==
'./index.vue'
)
.
forEach
((
path
)
=>
{
const
file
=
requireContext
(
path
)
components
[
file
.
default
.
name
]
=
file
.
default
if
(
file
.
default
.
name
)
{
components
[
file
.
default
.
name
]
=
file
.
default
}
else
{
console
.
error
(
`请给组件
${
path
}
加上name属性`
)
}
})
export
default
components
src/components/layout/index.js
View file @
4ebf41b7
...
...
@@ -3,7 +3,11 @@ const install = (Vue) => {
requireContext
.
keys
().
forEach
((
path
)
=>
{
// 每个文件的详细信息
const
file
=
requireContext
(
path
)
Vue
.
component
(
file
.
default
.
name
,
file
.
default
)
if
(
file
.
default
.
name
)
{
Vue
.
component
(
file
.
default
.
name
,
file
.
default
)
}
else
{
console
.
error
(
`请给组件
${
path
}
加上name属性`
)
}
})
}
...
...
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