Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cc201010
VueProject
Commits
928480d1
Commit
928480d1
authored
Nov 16, 2021
by
cc201010
Browse files
1. Port the Pokemon to individual components
parent
db160f34
Changes
3
Show whitespace changes
Inline
Side-by-side
poke-app/src/App.vue
View file @
928480d1
...
...
@@ -8,7 +8,6 @@ import HelloWorld from './components/HelloWorld.vue'
<
template
>
<img
alt=
"Vue logo"
src=
"./assets/logo.png"
/>
<HelloWorld
msg=
"Hello Vue 3 + FH + Vite"
/>
<Greet></Greet>
</
template
>
<
style
>
...
...
poke-app/src/components/pokemonComp.vue
0 → 100644
View file @
928480d1
<
template
>
<button
@
click=
"fetchPokemon"
>
Catch Pokemon
</button>
<ul>
<li
v-for=
"(pokeman,index) in list"
:key=
"index"
>
<p>
{{
pokeman
.
name
}}
</p>
<img
:src=
"`https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/$
{ index + 1}.png`" :alt="pokeman.name">
</li>
</ul>
</
template
>
<
script
>
export
default
{
name
:
'
pokemonTag
'
,
data
(){
return
{
list
:[]
}
},
methods
:{
async
fetchPokemon
(){
const
url
=
'
https://pokeapi.co/api/v2/pokemon?limit=151
'
const
data
=
await
fetch
(
url
);
const
pokemon
=
await
data
.
json
();
this
.
list
=
await
pokemon
.
results
;
}
},
}
</
script
>
\ No newline at end of file
poke-app/src/pages/Pokedex.vue
View file @
928480d1
<
script
>
import
pokemonTag
from
'
../components/pokemonComp.vue
'
export
default
{
name
:
'
PokedexPage
'
,
data
(){
return
{
list
:[]
}
},
methods
:{
async
fetchPokemon
(){
const
url
=
'
https://pokeapi.co/api/v2/pokemon?limit=151
'
const
data
=
await
fetch
(
url
);
const
pokemon
=
await
data
.
json
();
this
.
list
=
await
pokemon
.
results
;
components
:{
pokemonTag
,
}
},
}
</
script
>
<
template
>
<h1>
Pokedex Page
</h1>
<button
@
click=
"fetchPokemon"
>
Catch Pokemon
</button>
<ul>
<li
v-for=
"(pokeman,index) in list"
:key=
"index"
>
<p>
{{
pokeman
.
name
}}
</p>
<img
:src=
"`https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/$
{ index + 1}.png`" :alt="pokeman.name">
</li>
</ul>
<pokemonTag/>
</
template
>
\ No newline at end of file
Write
Preview
Supports
Markdown
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