我的 Next.js 应用程序有一个区域,它是照片库中选定的照片,因此当人们翻阅选定的图像或加载照片时,它必须保持固定的大小。我有一个响应式布局,但如果真的按下,我会说这个像素区域是 566px*425px。
我对如何实际做到这一点感到困惑。这是我能得到的最接近的结果,但问题是,当纵横比超过 566x425 时,图像会溢出,而对于纵横比低于 566x425 的图像,它将在 Y 方向上拉伸。我真正想要的是有一个固定的盒子,然后如果纵横比与最大尺寸不同,您会在侧面或顶部和底部看到信箱。
<div
style={{
position: 'relative',
width: '566px',
height: '425px',
}}
>
<Image
src={currCommit.image.url}
alt="Current Image"
layout={'fill'}
objectFit="cover"
/>
</div>
Run Code Online (Sandbox Code Playgroud) 我有一个多堆栈应用程序,我想在一个堆栈中部署 RDS,然后在后面的堆栈中部署一个连接到 RDS 的 Fargate 集群。
以下是 rds 的定义方式:
this.rdsSG = new ec2.SecurityGroup(this, `ecsSG`, {
vpc: props.vpc,
allowAllOutbound: true,
});
this.rdsSG.addIngressRule(ec2.Peer.anyIpv4(), ec2.Port.tcp(5432), 'Ingress 5432');
this.aurora = new rds.ServerlessCluster(this, `rds`, {
engine: rds.DatabaseClusterEngine.AURORA_POSTGRESQL,
parameterGroup: rds.ParameterGroup.fromParameterGroupName(this, 'ParameterGroup', 'default.aurora-postgresql10'),
vpc: props.vpc,
securityGroups: [this.rdsSG],
// more properties below
});
Run Code Online (Sandbox Code Playgroud)
有了这个添加入口规则,一切都很好,因为 RDS 和 Fargate 都在同一个 VPC 中,所以我可以很好地进行通信。我担心即使它在自己的 VPC 中,也要开放世界。
const ecsSG = new ec2.SecurityGroup(this, `ecsSG`, {
vpc: props.vpc,
allowAllOutbound: true,
});
const service = new ecs.FargateService(this, `service`, {
cluster,
desiredCount: 1,
taskDefinition,
securityGroups: [ecsSG],
assignPublicIp: …Run Code Online (Sandbox Code Playgroud) 我在设置 webpack 使用绝对路径时遇到问题。问题是我无法弄清楚如何使我的字体的加载路径与保存文件的实际位置相匹配。这是我的文件夹结构:
public
font
font1
font2
css
index.css
src
font
font1
font2
css
index.scss
webpack.config.js
Run Code Online (Sandbox Code Playgroud)
这就是我的 webpack 文件的样子。当我运行 webpack 时,它会正确地将字体文件添加到 public->font 中的正确位置,但是当我运行服务器时,它会尝试从以下位置获取字体:
http://localhost:8080/css/public/font/font1.ttf
代替:
http://localhost:8080/font/font1.tff
您可以看到它试图从 css 文件夹的相对路径而不是根目录中查找。我怎样才能解决这个问题?谢谢!
module.exports = {
entry: {
index: './src/javascript/index.js'
},
output: {
filename: './public/javascript/[name].js',
},
module: {
loaders: [
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader']
})
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
loader: 'file-loader?name=./public/font/[name].[ext]'
},
{
test: /\.(jpg|png)$/,
loader: 'file-loader?name=./public/image/[name].[ext]'
}
]
},
plugins: [
new ExtractTextPlugin('public/css/index.css')
]
};
Run Code Online (Sandbox Code Playgroud) 有人可以帮助我了解如何在 graphQL lambda 应用程序中抛出身份验证错误吗?我正在将 graphQL-yoga 与无服务器一起使用,我可以对请求进行身份验证,并返回我从 jwt 获得的用户,a{}表示没有令牌,或者如果令牌旧,则抛出身份验证错误。当我抛出一个错误时,它会在我的身份验证块的 catch 语句中被捕获,但我不知道如何从 lambda 实际返回它。
const lambda = new GraphQLServerLambda({
typeDefs,
context: ({ event, context }) =>
authenticate(event.headers.Authorization)
.then(user => ({ db: mainDb, user}))
.catch(e => {
console.log('Caught the auth error here');
throw e;
}),
Query: { \\ some queries here.... },
Mutation: { \\ some mutations here...}
});
Run Code Online (Sandbox Code Playgroud)
我怎样才能格式化错误或从正确的位置抛出它,以便我得到一个实际的格式化错误?相反,我Unexpected token I in JSON...在客户端出现错误。显然,我需要在我的过程中进行某种格式化,throw但对我来说如何做到这一点并不完全显而易见。
如果有帮助,请在我的导出部分。我正在尝试从 try/catch 到 then/catch 的所有内容,此时我似乎已经错过了捕捉错误的机会。有没有更好的方法来做到这一点?我需要的主要功能是能够进行身份验证、拒绝错误令牌,否则只{}为未登录的用户返回 a 。我最难找到允许未登录用户的自定义授权方,这就是我直接在我的 graphQL 端点中进行身份验证的原因
exports.server = …Run Code Online (Sandbox Code Playgroud) 我正在使用 gatsby 和 gatsby-plugin-tag-manager,但无法触发自定义事件。我的 gatsby-config.js 看起来像这样:
{
resolve: `gatsby-plugin-google-tagmanager`,
options: {
id: 'GTM-XXXXXXX',
includeInDevelopment: true,
defaultDataLayer: function() {
return {
pageType: window.pageType,
// platform: 'gatsby',
}
},
},
Run Code Online (Sandbox Code Playgroud)
当我在本地运行所有内容时,我可以使用以下代码正确触发我的事件:
window.dataLayer.push({
event: 'gatsby-course-splash-sign-up',
})
Run Code Online (Sandbox Code Playgroud)
问题是,当我将其静态部署到 s3 存储桶而不是在服务器上运行时,当页面视图触发时,其他任何事情都没有。有谁知道如何让自定义触发器工作?谢谢!
大家好,我很抱歉,如果这是一个菜鸟问题,但我使用的是python,我有一个问题,我复制一个数组但是当我修改副本时,它会影响原始.我想在边界矩阵中添加一个线性偏移到一组坐标:
boundaries = [[5.818, 0.0, 0.0], [0.0, 5.818, 0.0], [0.0, 0.0, 5.818]]
xyzCoord = [[0.0, 0.0, 0.0], [2.909, 2.909, 0.0], ...
extraX=[]
for i in range(0,len(xyzCoord)):
toAdd=[]
toAdd=xyzCoord[i]
toAdd[0]=toAdd[0]+boundaries[0][0]
print xyzCoord
Run Code Online (Sandbox Code Playgroud)
我期望的输出是xyzCoord不应该受到影响因为我复制(toAdd)然后修改它.奇怪的是,这个循环确实影响了我的xyzCoord:
输出是:
[[5.818, 0.0, 0.0], [0.0, 5.818, 0.0], [0.0, 0.0, 5.818]]
[[0.0, 0.0, 0.0], [2.909, 2.909, 0.0], ...
[[5.818, 0.0, 0.0], [8.727, 2.909, 0.0], ...
Run Code Online (Sandbox Code Playgroud)
编辑:对于上下文,我的想法是,我想最终使用转置值创建一个单独的列表,然后最终创建一个插入列表,但这部分让我感到高兴.即我理想地想创建:[[0.0,0.0,0.0],[5.818,0.0,0.0],[2.909,0.0,0.0],[8.727,2.909,0.0] ...]然后创建一个更大的循环对于Y和Z.这样我可以在XY和Z中传播一些坐标并且任意次数.
我正在为响应故事书配置webpack,并且导入语句路径出现问题。当我正常运行我的应用程序时,我的路径如下:
import { constructURLName } from "src/shared/utilities/stringManipulation";
我正在使用reactQL样板,并且已对其进行配置,以便它将基于src文件夹返回正确的模块。如何在故事书中复制它?故事书当前尝试在此处查找该stringManipulation文件:
/Users/me/development/reactQL/node_modules/src/shared/utilities/stringManipulation
因此它需要根据我的布局上一个目录:
node_modules
src
pages
...
shared
utilities
stringManipulation
Run Code Online (Sandbox Code Playgroud)
这是我的js / jsx文件规则:
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
query: {
babelrc: false,
presets: [
["env", { modules: false, exclude: ["transform-regenerator"] }],
"react"
],
plugins: [
"transform-object-rest-spread",
"syntax-dynamic-import",
"transform-regenerator",
"transform-class-properties",
"transform-decorators-legacy"
]
}
}
]
},
Run Code Online (Sandbox Code Playgroud)
如何正确设置src目录?谢谢!
我正在尝试使用 Ubuntu 14.04 创建一个 32 位 docker 映像,并且每次运行时uname,我都会看到它x86_64而不是i386. 谁能告诉我为什么会发生这种情况?
docker run talex5/lucid32 uname -m
Run Code Online (Sandbox Code Playgroud)
奇怪的是,当我以不同的方式查找架构类型时,它显示 32 位:
docker run i386/ubuntu:14.04 file /sbin/init
Run Code Online (Sandbox Code Playgroud)
/sbin/init:ELF 32 位 LSB 共享对象,Intel 80386,版本 1 (SYSV),动态链接(使用共享库),适用于 GNU/Linux 2.6.24,BuildID[sha1]=c394677bccc720a3bb4f4c42a48e008ff33e39b1,已剥离`
每当我下载不同的 32 位 docker 镜像时,甚至当我使用 debootstrap 创建自己的 docker 镜像时,都会发生这种情况。
谢谢!
我有一个ember应用程序,我正在尝试将时区添加到:
{
"name": "front-end",
"dependencies": {
"handlebars": "~1.3.0",
"jquery": "^1.11.1",
"ember": "1.8.1",
"ember-data": "~1.0.0-beta.14.1",
"ember-resolver": "~0.1.7",
"loader.js": "stefanpenner/loader.js#1.0.1",
"ember-cli-shims": "stefanpenner/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4",
"ember-load-initializers": "stefanpenner/ember-load-initializers#0.0.2",
"ember-qunit": "0.1.8",
"ember-qunit-notifications": "0.0.4",
"qunit": "~1.17.1",
"bootstrap": "~3.3.2",
"ember-simple-auth": "0.7.3",
"jquery-autosize": "~1.18.12",
"moment-timezone": "~0.3.0"
}
}
Run Code Online (Sandbox Code Playgroud)
我在我的Brocfile.js中使用此行加载js文件:
app.import('bower_components/moment-timezone/builds/moment-timezone-with-data-2010-2020.min.js');
Run Code Online (Sandbox Code Playgroud)
当我启动ember服务器时,甚至在我在任何自定义脚本中调用时刻之前,我都会收到以下错误:
Uncaught TypeError: Cannot read property 'tz' of undefined
Run Code Online (Sandbox Code Playgroud)
谁能告诉我加载时刻时区的正确方法?谢谢!
有谁知道如何在rspec中检查无效的枚举响应?我可以检查以确保枚举不是没有错误,但是当我检查以确保错误的枚举值不起作用时,我收到错误.这些是两个规格:
it 'is not valid without question type' do
expect(build(:question, question_type: nil)).to have(1).errors_on(:question_type)
end
it 'is not valid with a bad question type' do
expect(build(:question, question_type: :telepathy)).to have(1).errors_on(:question_type)
end
Run Code Online (Sandbox Code Playgroud)
这就是我的模型:
class Question < ActiveRecord::Base
enum question_type: [ :multiple_choice ]
validates :question_type, presence: true
end
Run Code Online (Sandbox Code Playgroud)
这是错误:
Failure/Error: expect(build(:question, question_type: :telepathy)).to have(1).errors_on(:question_type)
ArgumentError:
'telepathy' is not a valid question_type
Run Code Online (Sandbox Code Playgroud)
这是我的工厂:
FactoryGirl.define do
factory :question, :class => 'Question' do
question_type :multiple_choice
end
end
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助!
如何在graphQL阿波罗语法中添加字段解析器?使用graphql语法,如果我的讲座有问题,我可以这样做:
const LectureType = new GraphQLObjectType({
name: 'LectureType',
fields: () => ({
id: { type: GraphQLID },
questions: {
type: new GraphQLList(QuestionType),
resolve: ({ _id }, args, { models }) => models.Lecture.findQuestions(_id),
},
}),
});
Run Code Online (Sandbox Code Playgroud)
使用apollo graphQL的等效语法是什么?我认为我可以使用此解析器进行此类型定义:
type QuestionType {
id: String,
}
type LectureType {
id: String,
questions: [QuestionType],
}
const getOne = async ({ args, context }) => {
const { lecture, question } = constructIds(args.id);
const oneLecture = await model.get({ type: process.env.lecture, id: lecture });
oneLecture.questions = …Run Code Online (Sandbox Code Playgroud)