Skip to content

Commit

Permalink
Web > Parent, Child Data Passing
Browse files Browse the repository at this point in the history
  • Loading branch information
berkanumutlu committed Sep 19, 2024
1 parent 418ef58 commit 0f11e32
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
11 changes: 3 additions & 8 deletions project/resources/views/components/ExampleComponent.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script>
import Alert from '@project/resources/views/components/Alert.vue';
import {CheckCircleIcon, ExclamationCircleIcon, XCircleIcon} from '@heroicons/vue/24/outline';
import UserList from '@project/resources/views/components/UserList.vue';
export default {
components: {Alert},
components: {Alert, UserList},
data() {
return {
text: 'World',
Expand Down Expand Up @@ -268,13 +269,7 @@ export default {
:data-disabled="errors.length > 0 || form.fullname === '' ? true : null">Add
</button>
</form>
<div class="w-1/4 mx-auto my-4" v-if="users.length > 0">
<ul>
<li :key="index" v-for="(user, index) in users">{{ index + 1 + ') ' + user.fullname }}<small
class="ml-2 cursor-pointer" @click="deleteUser(index)">Remove</small>
</li>
</ul>
</div>
<user-list @delete="deleteUser" :users="users"></user-list>
</div>
</div>
</div>
Expand Down
24 changes: 24 additions & 0 deletions project/resources/views/components/UserList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script>
export default {
props: {
users: {
type: Array,
default: null
}
}
}
</script>

<template>
<div class="w-1/4 mx-auto my-4" v-if="users?.length > 0">
<ul>
<li :key="index" v-for="(user, index) in users">{{ index + 1 + ') ' + user.fullname }}<small
class="ml-2 cursor-pointer" @click="$emit('delete', index)">Remove</small>
</li>
</ul>
</div>
</template>

<style scoped>
</style>
1 change: 1 addition & 0 deletions project/resources/views/layouts/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ watch(() => currentRoute.name, (routeName) => {
}
}, {immediate: true});
</script>

<template>
<component :is="layout">
<RouterView/>
Expand Down

0 comments on commit 0f11e32

Please sign in to comment.