我正在使用 webpack 来捆绑我的 React 项目。我的项目依赖于以下组件的 material-ui:
material-ui/Dialog
material-ui/styles/getMuiTheme
material-ui/styles/MuiThemeProvider
material-ui/FlatButton
material-ui/TextField
Run Code Online (Sandbox Code Playgroud)
webpack-bundle-size-analyzer 报告 material-ui 占用 1.07MB 大小。下面是我的 webpack 配置文件:
const webpack = require('webpack');
const path = require('path');
const NpmInstallPlugin = require('npm-install-webpack-plugin');
const WebpackShellPlugin = require('webpack-shell-plugin');
var CompressionPlugin = require("compression-webpack-plugin");
const PATHS = {
react: path.join(__dirname, 'node_modules', 'react', 'dist', 'react.min.js'),
app: path.join(__dirname, 'src'),
build: path.join(__dirname, './dist')
};
module.exports = {
entry: {
app: './app/index.jsx',
android: './app/utils/platform_android.js',
ios: './app/utils/platform_ios.js',
web: './app/utils/platform_web.js',
vendor: [
'axios',
'react',
'react-dom',
'react-redux',
'react-router',
'react-router-redux',
'redux',
'redux-thunk',
'react-alert', …
Run Code Online (Sandbox Code Playgroud) 我使用内联样式的反应组件.它们可以定义如下.
const style= {
position: 'absolute',
left: 0,
right: 0,
bottom: '7.5%',
top: '5.2rem',
overflowY: 'auto',
},
Run Code Online (Sandbox Code Playgroud)
它有一些与css不同的语法,比如css中的'overflow-y'应该在内联样式中设置为overflowY.现在我徘徊如何设置这种样式-webkit-overflow-scrolling作为内联样式的反应?我尝试了下面的设置,但没有一个工作.
WebkitOverflowScrolling: 'touch',
'-webkit-overflow-scrolling': 'touch',
Run Code Online (Sandbox Code Playgroud) 我有两个反应组件,比如说 A 和 B。当 A 显示在页面上时,用户更改该页面上的某些内容,导致 A 内部的某些状态发生更改。然后用户单击导航到 B 的按钮router.push('/b')
。然后用户单击后退按钮并将页面导航到 A,这是由 完成的router.goBack()
。现在当前的 URL 是 A,但之前更新的状态已经消失。用户返回 A 时如何保持状态?
我使用Karma,Webpack,酶,PhantomJS来测试我的反应项目.当我运行以下命令运行测试用例时,
./node_modules/karma/bin/karma start config/karma.conf.js --single-run --browsers PhantomJS
Run Code Online (Sandbox Code Playgroud)
我得到以下错误:
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
ReferenceError: Can't find variable: require
at /dev/test/test.js:3
Run Code Online (Sandbox Code Playgroud)
在test.js的源代码的line3中,我没有使用require
,下面是代码:
import { expect } from 'chai';
Run Code Online (Sandbox Code Playgroud)
我想为什么PhantomJS抱怨这个错误.
下面是我的业力配置文件:
var path = require('path');
var webpackconf = require("./webpack.config")
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['mocha', 'chai'],
files: [
'../test/**/*.js'
],
preprocessors: {
// add webpack as preprocessor
'../src/**/*.js': ['babel'],
'../test/**/*.js': ['babel'],
'../src/**/*.less': ['babel']
},
webpack: { //kind of a copy of your webpack config
devtool: …
Run Code Online (Sandbox Code Playgroud) 我用来<textarea>
显示多行。我想用来"white-space:nowrap" and "text-overflow: ellipsis"
限制每一行显示在一行中,末尾带有“...”。下面是我设置的 css 样式,但“省略号”不起作用。
display: block;
width:400px;
height:20px;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
Run Code Online (Sandbox Code Playgroud)
有没有办法为标签做到这一点?
我正在使用这个库https://reactnavigation.org/docs/intro/来通过react-native构建android.我可以在Android设备上进行导航,但是如何让屏幕从右侧滑入并从左侧淡入.似乎这种行为发生在iOS设备上,而不是在Android中.Android应用程序有任何动画配置吗?
请看下面的动画.这是在iOS中记录的.
我有 scss 代码:
.a {
height: 100px;
width: 100px;
}
.b {
@extend .a;
height: 200px;
}
Run Code Online (Sandbox Code Playgroud)
编译后的 css 看起来像:
.a, .b {
height: 100px;
width: 100px;
}
.b {
height: 200px;
}
Run Code Online (Sandbox Code Playgroud)
当我应用这种样式时,dom 的<div class="a b">
高度将为 ,100px
而不是200px
。在这种情况下,如何使 css 的高度为 200px?
我用来Terraform
将 lambda 发布到 AWS。当我部署到 AWS 时它工作正常,但在针对localstack
.
下面是我的.tf
配置文件,您可以看到我将 lambda 端点配置为http://localhost:4567
.
provider "aws" {
profile = "default"
region = "ap-southeast-2"
endpoints {
lambda = "http://localhost:4567"
}
}
variable "runtime" {
default = "python3.6"
}
data "archive_file" "zipit" {
type = "zip"
source_dir = "crawler/dist"
output_path = "crawler/dist/deploy.zip"
}
resource "aws_lambda_function" "test_lambda" {
filename = "crawler/dist/deploy.zip"
function_name = "quote-crawler"
role = "arn:aws:iam::773592622512:role/LambdaRole"
handler = "handler.handler"
source_code_hash = "${data.archive_file.zipit.output_base64sha256}"
runtime = "${var.runtime}"
}
Run Code Online (Sandbox Code Playgroud)
以下是 docker compose …
我使用这个命令在K8S上部署了一个elasticsearchhelm install elasticsearch elastic/elasticsearch
集群。
我可以看到 Pod 正在运行:
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
elasticsearch-master-0 0/1 Running 0 4m30s
kibana-kibana-5697fc485b-qtzzl 0/1 Running 0 130m
Run Code Online (Sandbox Code Playgroud)
服务看起来也不错:
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
elasticsearch-master ClusterIP 10.105.59.248 <none> 9200/TCP,9300/TCP 4m50s
elasticsearch-master-headless ClusterIP None <none> 9200/TCP,9300/TCP 4m50s
kibana-kibana ClusterIP 10.104.31.124 <none> 5601/TCP 6d7h
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 10d
Run Code Online (Sandbox Code Playgroud)
但deployment
elasticsearch没有:
$ kubectl get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
kibana-kibana 0/1 1 …
Run Code Online (Sandbox Code Playgroud) 我在 AWS 中创建 EKS 集群并使用此命令创建服务帐户eksctl create iamserviceaccount --name alb-ingress-controller --cluster $componentName --attach-policy-arn $serviceRoleArn --approve --override-existing-serviceaccounts
。\n该命令的输出为:
[\xe2\x84\xb9] using region ap-southeast-2\n[\xe2\x84\xb9] 1 existing iamserviceaccount(s) (default/alb-ingress-controller) will be excluded\n[\xe2\x84\xb9] 1 iamserviceaccount (default/alb-ingress-controller) was excluded (based on the include/exclude rules)\n[!] metadata of serviceaccounts that exist in Kubernetes will be updated, as --override-existing-serviceaccounts was set\n[\xe2\x84\xb9] no tasks\n
Run Code Online (Sandbox Code Playgroud)\n我不确定是否创建成功。
\n我使用此命令eksctl get iamserviceaccount
来验证结果,但收到错误响应:
Error: getting iamserviceaccounts: no output "Role1" in stack "eksctl-monitor-addon-iamserviceaccount-default-alb-ingress-controller"
我也尝试运行kubectl get serviceaccount
,但出现错误:Error …
css ×3
reactjs ×3
javascript ×2
webpack ×2
amazon-eks ×1
android ×1
aws-lambda ×1
css3 ×1
enzyme ×1
html ×1
karma-mocha ×1
kubernetes ×1
localstack ×1
material-ui ×1
npm ×1
react-native ×1
sass ×1
terraform ×1