-
Notifications
You must be signed in to change notification settings - Fork 834
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
chore(deps): update vue/core to v3.5.10 #3206
Changes from all commits
9596850
c735a28
646799f
8ec86c6
092080e
f643a66
8079a4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
<view class="nut-comment-images__play"></view> | ||
</view> | ||
<!-- images --> | ||
<template v-for="(itI, index) in images" :key="itI.id"> | ||
<template v-for="(itI, index) in images" :key="index"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 考虑使用唯一标识符作为 v-for 的 key 在 v-for 指令中,使用索引(index)作为 key 可能会导致一些渲染问题,特别是当列表项目顺序发生变化时。建议使用每个图片项目的唯一标识符作为 key,如果有的话。 如果确实需要使用索引,请考虑添加注释解释原因,以便其他开发者理解这个决定。 建议修改如下: - <template v-for="(itI, index) in images" :key="index">
+ <template v-for="(itI, index) in images" :key="itI.id || index"> 如果
|
||
<view | ||
v-if="(type == 'multi' && videos.length + index < 9) || type != 'multi'" | ||
class="nut-comment-images__item nut-comment-images__item--imgbox" | ||
|
@@ -37,16 +37,7 @@ import { createComponent } from '@/packages/utils/create' | |
const { create } = createComponent('comment-images') | ||
import { Right } from '@nutui/icons-vue' | ||
|
||
interface VideosType { | ||
id?: number | string | ||
mainUrl: string | ||
videoUrl: string | ||
} | ||
interface ImagesType { | ||
smallImgUrl: string | ||
bigImgUrl: string | ||
imgUrl: string | ||
} | ||
import { VideosType, ImagesType } from '../type' | ||
export default create({ | ||
props: { | ||
type: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface VideosType { | ||
id?: number | string | ||
mainUrl: string | ||
videoUrl: string | ||
} | ||
Comment on lines
+1
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 考虑对
建议的改进示例: /**
* 表示单个视频项的接口
*/
export interface VideoType {
/** 视频的唯一标识符 */
id?: string
/** 视频的主要显示URL */
mainUrl: URL
/** 视频的播放URL */
videoUrl: URL
} 使用 |
||
export interface ImagesType { | ||
smallImgUrl: string | ||
bigImgUrl: string | ||
imgUrl: string | ||
} | ||
Comment on lines
+6
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 建议对
建议的改进示例: /**
* 表示单个图片项的不同尺寸URL
*/
export interface ImageType {
/** 小尺寸图片URL */
smallImgUrl: URL
/** 大尺寸图片URL */
bigImgUrl: URL
/**
* 原始尺寸图片URL
* @deprecated 考虑使用 originalImgUrl 作为更清晰的命名
*/
imgUrl: URL
} 这个改进版本使用了更具描述性的名称,并添加了注释以提高可读性和可维护性。 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface SkuInfo { | ||
name: string | ||
id: number | ||
active: boolean | ||
disable: boolean | ||
[props: string]: any | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 建议重新考虑使用 使用 例如,如果可能的话,您可以尝试以下方法之一:
这些建议可以帮助在保持灵活性的同时提高类型安全性。 🧰 Tools🪛 GitHub Check: CodeFactor
|
||
} | ||
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.
建议使用唯一标识符作为 key
在 v-for 指令中,将 key 从
itI.id
更改为index
可能会导致性能问题和意外行为,特别是在列表项被添加、删除或重新排序时。建议:
itI
对象中有唯一标识符(如 id),请使用该标识符作为 key。这种方法比单独使用索引更可靠,但仍不如使用真正的唯一标识符。