728x90
[목표]
간단한 예제를 만들기 위해
버튼을 생성한다.
해당 버튼을 클릭하면 URL 이동을 한다.
router를 사용하여 구현해보자
버튼을 생성하고
버튼을 누른다면 '/teams'로 이동한다.
수정된 소스
[UsersList.vue]
<template>
<button @click="confirmInput">라우터 테스트 버튼</button>
<ul>
<user-item v-for="user in users" :key="user.id" :name="user.fullName" :role="user.role"></user-item>
</ul>
</template>
<script>
import UserItem from './UserItem.vue';
export default {
components: {
UserItem,
},
inject: ['users'],
methods: {
confirmInput(){
this.$router.push('/teams');
},
}
};
</script>
<style scoped>
ul {
list-style: none;
margin: 2rem auto;
max-width: 20rem;
padding: 0;
}
</style>
'데일리 공부 기록' 카테고리의 다른 글
hands on vue3 - router 관련 퀴즈 풀어보기(router-link에 변수사용하기) (0) | 2023.03.23 |
---|---|
hands on vue3 - 주어진 소스를 보고 router에 대한 문제를 풀어봐라(router 파라미터사용하기) (0) | 2023.03.22 |
hands on vue3 - 조건에 따라 option disabled 다르게 먹이기 (0) | 2023.03.22 |
hands on vue3 - router가 active될 때 css를 위한 커스텀 class명 (0) | 2023.03.22 |
hands on vue3 - router-link 태그를 이용해보기 (0) | 2023.03.21 |