-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
закончил с 4 задачей - через computed и map создал фильтрованный масс…
…ив и с ним работал и 5 задачу - если честно очень сложно пока, пошел в гости к своему другу и только он смог помочь, небольшая каша в голове
- Loading branch information
sergeykalabin
committed
Dec 25, 2024
1 parent
9ae1ed5
commit a1313e4
Showing
2 changed files
with
101 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,19 +32,35 @@ export const emails = [ | |
export default defineComponent({ | ||
name: 'MarkedEmailsApp', | ||
|
||
setup() {}, | ||
setup() { | ||
|
||
const emailsArrow = ref(emails); | ||
|
||
const inputEmail = ref(''); | ||
|
||
const filteredEmails = computed(() => { | ||
return emailsArrow.value.map(email => ({ | ||
email, | ||
marked: email.toLowerCase().includes( inputEmail.value.toLowerCase() ) && inputEmail.value !== '', | ||
})) | ||
}) | ||
|
||
return { | ||
emailsArrow, | ||
inputEmail, | ||
filteredEmails, | ||
} | ||
}, | ||
|
||
template: ` | ||
<div> | ||
<!-- {{ filteredEmails }} --> | ||
<div class="form-group"> | ||
<input type="search" aria-label="Search" /> | ||
<input type="search" aria-label="Search" v-model.trim="inputEmail" /> | ||
</div> | ||
<ul aria-label="Emails"> | ||
<li> | ||
[email protected] | ||
</li> | ||
<li class="marked"> | ||
[email protected] | ||
<li v-for="email in filteredEmails" :class="{ 'marked': email.marked }"> | ||
{{ email.email }} | ||
</li> | ||
</ul> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,104 @@ | ||
import { defineComponent } from 'vue' | ||
// import { getMeetup } from './meetupsService.ts' | ||
import { defineComponent, ref, watch } from 'vue' | ||
import { getMeetup } from './meetupsService.ts' | ||
|
||
export default defineComponent({ | ||
name: 'SelectedMeetupApp', | ||
|
||
setup() {}, | ||
setup() { | ||
const currentId = ref(1) | ||
const meetupTitle = ref('') | ||
|
||
const pages = [ | ||
{ | ||
id: 'meetup-id-1', | ||
name: 'meetupId', | ||
value: 1, | ||
}, | ||
{ | ||
id: 'meetup-id-2', | ||
name: 'meetupId', | ||
value: 2, | ||
}, | ||
{ | ||
id: 'meetup-id-3', | ||
name: 'meetupId', | ||
value: 3, | ||
}, | ||
{ | ||
id: 'meetup-id-4', | ||
name: 'meetupId', | ||
value: 4, | ||
}, | ||
{ | ||
id: 'meetup-id-5', | ||
name: 'meetupId', | ||
value: 5, | ||
}, | ||
] | ||
|
||
const prevMeetup = () => { | ||
currentId.value-- | ||
} | ||
|
||
const nextMeetup = () => { | ||
currentId.value++ | ||
} | ||
|
||
const fetchMeetups = async id => { | ||
try { | ||
const meetup = await getMeetup(id) | ||
meetupTitle.value = meetup.title | ||
} catch (e) { | ||
console.error(e) | ||
return '' | ||
} | ||
} | ||
|
||
watch( | ||
currentId, | ||
newId => { | ||
fetchMeetups(newId) | ||
}, | ||
{ immediate: true }, | ||
) | ||
|
||
return { | ||
meetupTitle, | ||
currentId, | ||
prevMeetup, | ||
nextMeetup, | ||
pages, | ||
} | ||
}, | ||
|
||
template: ` | ||
<div class="meetup-selector"> | ||
<div class="meetup-selector__control"> | ||
<button class="button button--secondary" type="button" disabled>Предыдущий</button> | ||
<button class="button button--secondary" type="button" :disabled="currentId === 1" @click="prevMeetup">Предыдущий</button> | ||
<div class="radio-group" role="radiogroup"> | ||
<div class="radio-group__button"> | ||
<input | ||
id="meetup-id-1" | ||
class="radio-group__input" | ||
type="radio" | ||
name="meetupId" | ||
value="1" | ||
/> | ||
<label for="meetup-id-1" class="radio-group__label">1</label> | ||
</div> | ||
<div class="radio-group__button"> | ||
<input | ||
id="meetup-id-2" | ||
class="radio-group__input" | ||
type="radio" | ||
name="meetupId" | ||
value="2" | ||
/> | ||
<label for="meetup-id-2" class="radio-group__label">2</label> | ||
</div> | ||
<div class="radio-group__button"> | ||
<input | ||
id="meetup-id-3" | ||
class="radio-group__input" | ||
type="radio" | ||
name="meetupId" | ||
value="3" | ||
/> | ||
<label for="meetup-id-3" class="radio-group__label">3</label> | ||
</div> | ||
<div class="radio-group__button"> | ||
<input | ||
id="meetup-id-4" | ||
class="radio-group__input" | ||
type="radio" | ||
name="meetupId" | ||
value="4" | ||
/> | ||
<label for="meetup-id-4" class="radio-group__label">4</label> | ||
</div> | ||
<div class="radio-group__button"> | ||
<div v-for="page in pages" :key="page.id" class="radio-group__button"> | ||
<input | ||
id="meetup-id-5" | ||
v-model="currentId" | ||
class="radio-group__input" | ||
type="radio" | ||
name="meetupId" | ||
value="5" | ||
:id="page.id" | ||
:name="page.name" | ||
:value="page.value" | ||
/> | ||
<label for="meetup-id-5" class="radio-group__label">5</label> | ||
<label :for="page.id" class="radio-group__label">{{ page.value }}</label> | ||
</div> | ||
</div> | ||
<button class="button button--secondary" type="button">Следующий</button> | ||
<button class="button button--secondary" type="button" :disabled="currentId === 5" @click="nextMeetup">Следующий</button> | ||
</div> | ||
<div class="meetup-selector__cover"> | ||
<div class="meetup-cover"> | ||
<h1 class="meetup-cover__title">Some Meetup Title</h1> | ||
<h1 class="meetup-cover__title">{{meetupTitle}}</h1> | ||
</div> | ||
</div> | ||
</div> | ||
`, | ||
}) | ||
}) |