我在尝试使用 Bulma 库创建一个包含一些对齐内容的 3 个盒子的响应式网格时遇到了问题。如果可能的话,我想让它仍然保持盒子内的水平。
任何帮助,将不胜感激。
这是我期望的结果:
但是当减小宽度时,它会中断:
这是我正在使用的代码:
<div className="columns sub">
{this.props.options.map(option => (
<div className="column is-one-third" key={option.id}>
<div
name={option.id}
className={
`box ` +
(this.props.optionToBeChosen === option.id
? "box-is-active"
: "")
}
onClick={() => this.props.onClick(option.id)}
>
<div className="level is-mobile">
<div className="level-item level-left">
<div>
<p className="box-text-title">{option.title}</p>
<p className="box-text-small">{option.description}</p>
<p className="box-text-small">{option.description2}</p>
</div>
</div>
<div className="level-item level-right has-text-right">
<div>
<p className="box-text-demo">{option.cta}</p>
</div>
</div>
</div>
</div>
</div>
))}
</div>
Run Code Online (Sandbox Code Playgroud) 我正在尝试复制我们在 swiftui 中创建带有默认可选参数的函数的方式。
func greet(_ person: String, nicely: Bool = true) {
if nicely == true {
print("Hello, \(person)!")
} else {
print("Oh no, it's \(person) again...")
}
}
Run Code Online (Sandbox Code Playgroud)
可以用两种不同的方式调用
greet("Taylor")
greet("Taylor", nicely: false)
Run Code Online (Sandbox Code Playgroud)
是否可以使用相同的逻辑创建 SwiftUI 视图?我想创建一个具有“默认可选”参数的组件,这样我可以将其称为:
DividerItem(...)
DividerItem(..., isBold: true)
Run Code Online (Sandbox Code Playgroud)
非常感谢!
首先,我想道歉,因为我的SQL知识水平仍然很低。基本上,问题如下:我有两个不同的表,它们之间没有直接关系,但是它们共享两列:storm_id和userid。
基本上,我想查询来自storm_id的所有帖子,这些帖子不是来自被禁止的用户和一些额外的过滤器。
这些是模型:
class Post(db.Model):
id = db.Column(db.Integer, primary_key = True)
...
userid = db.Column(db.String(100))
...
storm_id = db.Column(db.Integer, db.ForeignKey('storm.id'))
Run Code Online (Sandbox Code Playgroud)
class Banneduser(db.Model):
id = db.Column(db.Integer, primary_key=True)
sn = db.Column(db.String(60))
userid = db.Column(db.String(100))
name = db.Column(db.String(60))
storm_id = db.Column(db.Integer, db.ForeignKey('storm.id'))
Run Code Online (Sandbox Code Playgroud)
Post和Banneduser都是另一个表(风暴)子级。这是我要输出的查询。如您所见,我正在尝试过滤:
有限制(我把它与查询分开,因为elif还有其他过滤器)
# we query banned users id
bannedusers = db.session.query(Banneduser.userid)
# we do the query except the limit, as in the if..elif there are more filtering queries
joined = db.session.query(Post, Banneduser)\
.filter(Post.storm_id==stormid)\
.filter(Post.verified==True)\
# …Run Code Online (Sandbox Code Playgroud)当我启动我的 React 应用程序时,我在控制台中有一个奇怪的输出,我真的很好奇它:
我想我可能缺少引用应用程序版本的参数,只需要一些 Stackoverflow 清晰度。这是我的 main.js,您可以在其中看到问题(第 42 行):
谢谢!
我在表单验证方面遇到了麻烦.国家/地区列表生成正确,以前的表单工作正常.它只会在POST请求中中断.
这是我的forms.py:
from wtforms import Form, BooleanField, SelectField, \
StringField, PasswordField, SubmitField, validators, \
RadioField
from ..models import User
from pycountry import countries
...
## Account settings
# We get all COUNTRIES
COUNTRIES = [(c.name, c.name) for c in countries]
# edit profile
class ProfileForm(Form):
username = StringField('name',[validators.Length(min=1, max=120), validators.InputRequired])
email = StringField('email', [validators.Length(min=6, max=120), validators.Email()])
company = StringField('name',[validators.Length(min=1, max=120)])
country = SelectField('country', choices=COUNTRIES)
news = BooleanField('news')
Run Code Online (Sandbox Code Playgroud)
这是观点:
@user.route('/profile/', methods=['GET', 'POST'])
@login_required
def profile():
userid = current_user.get_id()
user = User.query.filter_by(id=userid).first_or_404() …Run Code Online (Sandbox Code Playgroud) 我努力了几个小时来显示更新文档的最终值(通过 mongoose updateOne)。我成功修改了它,因为当我在 Postman 上调用端点时可以看到“nModified: 1”,但我无法输出实际的最终文档 - 即使使用参数{new:true}
这是路线的代码:
// 3. We check if blockid is in this project
Block.findById(req.params.blockid)
.then(block => {
if (!block) {
errors.noblock = "Block not found";
return res.status(404).json(errors);
}
// 4. We found the block, so we modify it
Block.updateOne(
{ _id: req.params.blockid },
{ $set: blockFields }, // data to be updated
{ new: true }, // flag to show the new updated document
(err, block) => {
if (err) {
errors.noblock …Run Code Online (Sandbox Code Playgroud) 我有一个 ObservedObject AppStatus 类,它内部有多个 Published 类。如果我只在孩子方面有水平,一切都会很好。
当我有一个 RecordingTimeManager 类,其中有另一个变量(2 级子级)时,问题就出现了。当我按下按钮时,变量 maxRecordingTime 正在正确更改,它会打印“15 15Seconds”,但 foregroundColor 不会触发更改。我不确定这是否是 SwiftUI 错误,或者我应该以另一种方式构建关系:
// 应用程序状态
// Recording
@Published var recordingTimeManager: RecordingTimeManager = RecordingTimeManager()
Run Code Online (Sandbox Code Playgroud)
// 录音时间管理器
class RecordingTimeManager {
@Published var maxRecordingTime: TimeSeletedTime = .sixteenSeconds
...
Run Code Online (Sandbox Code Playgroud)
// 需要根据 maxRecordingTime 更改更改不透明度的 SwiftUI 组件(.foregroundColor 未更改)
Button {
appStatus.recordingTimeManager.maxRecordingTime = .fifteenSeconds
print("15 \(appStatus.recordingTimeManager.maxRecordingTime)")
} label: {
Text("15")
.font(Font.custom("BwGradual-Bold", size: 15))
.foregroundColor(appStatus.recordingTimeManager.maxRecordingTime == .fifteenSeconds ? CLAPSOFFWHITE : TRIBESGREY)
}
Run Code Online (Sandbox Code Playgroud)
非常感谢,
我在节点+快速路由方面遇到问题。我在 IDE webstorms 中默认提供了一个路由架构。我不确定我是否配置好了一切,因为我遇到了这个错误。
我可以正确执行 GET /users 和 POST /users,并在邮递员上获得正确的结果。
路线/user.js
const express = require('express');
const router = express.Router();
const _ = require('lodash');
const {ObjectID} = require('mongodb');
const {mongoose} = require('../db/mongoose')
const {User} = require('../db/models/users')
const {Project} = require('../db/models/projects')
const {Dialog} = require('../db/models/dialogs')
(...)
router.get('/users/:userid', (req, res) => {
var id = req.params.userid.toString();
if (!ObjectID.isValid(id)) {
return res.status(404).send();
}
User.findByID(id).then((user) => {
if (!user) {
return res.status(404).send();
}
res.send({user});
}).catch(() => {
res.status(404).send();
});
});
Run Code Online (Sandbox Code Playgroud)
模型/user.js
const mongoose = require('mongoose'); …Run Code Online (Sandbox Code Playgroud) 我有几个级联模式需要根据某些后台进程进行刷新。为了实现这一点,我创建了一个结构体,其中包含 UI 的所有逻辑,并使用 UIHostingController.init(rootView: views) 调用了几个 SwiftUI 视图。
当我想通过单击子视图中的按钮来关闭视图时,挑战就来了。我正在尝试使用 @State 和 @Binding 但绑定迫使我在子视图中初始化变量。
这是孩子的代码:
struct ResultViewSilence: View {
@Binding var isDismissView: Bool
var hasSilence: Bool
let photolibrary = PhotoLibrary()
init(hasSilence: Bool) {
self.hasSilence = hasSilence
<--- here is where is asking to initialize isDismissView, but it should not be needed
}
Run Code Online (Sandbox Code Playgroud)
通过这样做,我能够初始化 isDismissView...
init(hasSilence: Bool, isDismissView: Binding<Bool>?) {
...
self._isDismissView = isDismissView!
Run Code Online (Sandbox Code Playgroud)
但是如果我这样做,那么它会在父级中中断,因为我无法将 @State 作为参数传递给 UIHostingController 并且它是必需的。
如果我这样做,我会得到的错误是:
"Accessing State's value outside of being installed on a View. This will …Run Code Online (Sandbox Code Playgroud)