mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-04 19:37:18 +00:00
49 lines
896 B
Vue
49 lines
896 B
Vue
<template>
|
|
<div class="container clearfix">
|
|
<h1>Nested routes example</h1>
|
|
<h2>Users list</h2>
|
|
<ul class="users">
|
|
<li v-for="user in users">
|
|
<router-link :to="{ name: 'users-id', params: { id: user.id } }">{{ user.name }}</router-link>
|
|
</li>
|
|
</ul>
|
|
<router-view></router-view>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios'
|
|
|
|
export default {
|
|
data () {
|
|
return axios.get('https://jsonplaceholder.typicode.com/users')
|
|
.then((res) => {
|
|
return { users: res.data }
|
|
})
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.users {
|
|
margin: 10px 0;
|
|
float: left;
|
|
list-style-type: none;
|
|
}
|
|
.users li a {
|
|
display: inline-block;
|
|
width: 200px;
|
|
border: 1px #ddd solid;
|
|
padding: 10px;
|
|
text-align: left;
|
|
color: #222;
|
|
text-decoration: none;
|
|
}
|
|
.users li a:hover {
|
|
color: #41b883;
|
|
}
|
|
.router-link-active {
|
|
color: #41b883 !important;
|
|
}
|
|
</style>
|