小编jam*_*mes的帖子

LazyVGrid 中的 SwiftUI 中心项目

我是 SwiftUI 的新手,正在尝试将元素置于LazyVGrid视图中的中心。

这是我目前拥有的:

在此输入图像描述

使用:

var body: some View {
    ZStack {
        Color(red: 75/255, green: 0, blue: 130/255).ignoresSafeArea()
        VStack {
            LazyVGrid(columns: [GridItem(.adaptive(minimum: 30))], alignment: .center, spacing: 10) {
                let letters = wordToArray(word: testWord)
                ForEach(Array(letters.enumerated()), id: \.offset) { letter in
                    Text(String(letter.element).capitalized)
                        .foregroundColor(.blue)
                        .frame(width:30, height: 40)
                        .background(Color.yellow)
                        .cornerRadius(5)
                }
            }
            .padding()
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但正如您所看到的,这只将元素向左对齐 - 我也不知道可能需要显示的字符数。我还希望保持它们之间的间距与上面相同。

任何帮助将不胜感激!

谢谢。

xcode ios swift swiftui

7
推荐指数
1
解决办法
5269
查看次数

Next.js 构建使用 <img> 标签失败

我最近开始Next.js做网站,我一直在使用的混合Imageimg各种用例。

我知道这Image是内置的Next.js并且是更好的选择,但在某些情况下我不知道我加载的图像的大小或比例,因此img似乎更适合。

在我最近的项目中,这是我的npm run build命令第一次失败:

1:7  Error: Do not use <img>. Use Image from 'next/image' instead. See https://nextjs.org/docs/messages/no-img-element.
Run Code Online (Sandbox Code Playgroud)

我的其他 Next.js 项目不会以这种方式失败,并且使用相同的next.config.js. 有谁知道为什么会这样?

html node.js npm reactjs next.js

1
推荐指数
1
解决办法
519
查看次数

标签 统计

html ×1

ios ×1

next.js ×1

node.js ×1

npm ×1

reactjs ×1

swift ×1

swiftui ×1

xcode ×1