-
Notifications
You must be signed in to change notification settings - Fork 1
Resolved 03.30-03.50 #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Добавляю преподавателя (@ShGKme) для код-ревью. |
ShGKme
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Принято, но обратите внимание на комментарии
| <UiInput v-model.trim="query" type="search" placeholder="Поиск" aria-label="Поиск" small /> | ||
| </UiFormGroup> | ||
| <EmailList :emails="markedEmails" /> | ||
| <EmailList :emails="markedEmails" @remove="(value)=>{removeEmailByIndex(value)}"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В директиву v-on можно передавать сразу тело обработчика события, а параметр получать из $event.
@remove="removeEmailByIndex($event)"
А так как просто вызывается другая функция с этим параметром - можно просто передать саму функцию
@remove="removeEmailByIndex"
| <UiCounter v-model:count="count1" @update:count="(value)=>{count1 = value}"/> | ||
| </p> | ||
| <p style="margin: 1em 0"> | ||
| <UiCounter v-model:count="count2" :min="1" :max="3" /> | ||
| <UiCounter v-model:count="count2" :min="1" :max="3" @update:count="(value)=>{count2 = value}"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Обработка @update:count здесь не нужна, так как она уже выполняется в директиве двустороннего связывания v-model:count
| function update(operation) { | ||
| operation == 'inc' ? emit('update:count', props.count + 1) : emit('update:count', props.count - 1) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тернарный оператор здесь используется не совсем корректно. Это именно оператор (как a + b), который выполняет вычисление и возвращает результат - 2-ой или 3-ий операнд. Здесь оба вычисляемых значения - undefined (так как emit()) не возвращает значения. А результат всего оператора не используется.
Более корректным будет либо использовать ветвление:
if (operation == 'inc') {
emit('update:count', props.count + 1)
} else {
emit('update:count', props.count - 1)
}Либо использовать тернарный оператор для вычисления действительно значения
emit('update:count', operation == 'inc' ? props.count + 1 : props.count - 1)| data() { | ||
| return { | ||
| weatherData: getWeatherData(), | ||
| } | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это не Composition API 👀
| computed: { | ||
| weatherIcon() { | ||
| return WeatherConditionIcons[this.data.current.weather.id] | ||
| }, | ||
|
|
||
| temperature() { | ||
| return (this.data.current.temp - 273.15).toFixed(1) | ||
| }, | ||
|
|
||
| details() { | ||
| return { | ||
| 'Давление, мм рт. ст.': (this.data.current.pressure * 0.750062).toFixed(0), | ||
| 'Влажность, %': this.data.current.humidity, | ||
| 'Облачность, %': this.data.current.clouds, | ||
| 'Ветер, м/с': this.data.current.wind_speed, | ||
| } | ||
| }, | ||
|
|
||
| isNight() { | ||
| const currentTime = this.data.current.dt | ||
| const sunriseTime = this.data.current.sunrise | ||
| const sunsetTime = this.data.current.sunset | ||
| return currentTime < sunriseTime || currentTime > sunsetTime | ||
| }, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
И это 👀
No description provided.