mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-23 07:31:26 +00:00
Moved "number selected"... but it doesn't update. Why?
This commit is contained in:
@@ -1,18 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<h1>VMail Inbox</h1>
|
<h1>VMail Inbox</h1>
|
||||||
|
|
||||||
|
Number selected: {{selectedEmailIds.size}}
|
||||||
|
|
||||||
<MailTable :emails="emails" />
|
<MailTable :emails="emails" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import MailTable from '@/components/MailTable.vue';
|
import MailTable from '@/components/MailTable.vue';
|
||||||
import { ref } from 'vue';
|
import useEmailSelection from '../composition/useEmailSelection';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async setup(props, {attrs, slots}){
|
async setup(props, {attrs, slots}){
|
||||||
let response = await fetch('/api/emails');
|
let response = await fetch('/api/emails');
|
||||||
let {emails} = await response.json();
|
let {emails} = await response.json();
|
||||||
|
|
||||||
return {emails}
|
let {selectedEmailIds} = useEmailSelection();
|
||||||
|
|
||||||
|
return {emails, selectedEmailIds}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
MailTable
|
MailTable
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<table>
|
<table>
|
||||||
Number selected: {{selectedEmailIds.size}}
|
|
||||||
<thead>
|
|
||||||
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="email in emails" :key="email.id" :class="[email.read ? 'read' : '']">
|
<tr v-for="email in emails" :key="email.id" :class="[email.read ? 'read' : '']">
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { ref } from 'vue';
|
|||||||
|
|
||||||
export const useEmailSelection = function(){
|
export const useEmailSelection = function(){
|
||||||
let selectedEmailIds = ref(new Set(['1', '5']))
|
let selectedEmailIds = ref(new Set(['1', '5']))
|
||||||
|
|
||||||
let toggleEmailSelection = (id) => {
|
let toggleEmailSelection = (id) => {
|
||||||
if(selectedEmailIds.value.has(id)) {
|
if(selectedEmailIds.value.has(id)) {
|
||||||
selectedEmailIds.value.delete(id)
|
selectedEmailIds.value.delete(id)
|
||||||
|
|||||||
Reference in New Issue
Block a user