我已经创建了一个docker镜像,它使用容器内部的webpack来提供简单的反应应用程序,但我在浏览器中什么也得不到.
这是我的配置文件
package.json
{
"name": "invas_client",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack --inline --content-base ."
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "^0.14.7",
"react-dom": "^0.14.7",
"react-router": "^2.0.0"
},
"devDependencies": {
"babel-core": "^6.5.1",
"babel-loader": "^6.2.2",
"babel-preset-es2015": "^6.5.0",
"babel-preset-react": "^6.5.0",
"http-server": "^0.8.5",
"webpack": "^1.12.13",
"webpack-dev-server": "^1.14.1"
}
}
Run Code Online (Sandbox Code Playgroud)
webpack.config.js
module.exports = {
entry: './index.js',
output: {
filename: 'bundle.js',
publicPath: ''
},
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }
]
}
}
Run Code Online (Sandbox Code Playgroud)
Dockerfile …
DELETE由于CORS,我无法允许来自我的API服务器的请求.
// enable CORS
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET", "PUT", "POST", "DELETE", "OPTIONS");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization");
next();
});
Run Code Online (Sandbox Code Playgroud)
我收到控制台错误说:
XMLHttpRequest cannot load http://localhost:8080/api/users/57f5036645c04700128d4ee0. Method DELETE is not allowed by Access-Control-Allow-Methods in preflight response
我怎样才能使DELETE请求,就像GET,PUT和POST要求?
我正在尝试访问 npm 脚本本身中的环境变量,如下所示:
"scripts": {
"test": "istanbul cover node_modules/.bin/_mocha --root ../SERVER/routes -- --recursive"
},
Run Code Online (Sandbox Code Playgroud)
并像这样启动这个脚本:
SERVER=somewhere npm test
Run Code Online (Sandbox Code Playgroud)
如何SERVER在 package.json 本身的 npm 脚本中获取变量的解析值?
尝试在python服务器上集成Google Firestore API
...
File "/home/daffolap-355/repos/subscriptions/appvendor/firebase_admin/firestore.py", line 28, in <module>
raise ImportError('Failed to import the Cloud Firestore library for Python. Make sure '
ImportError: Failed to import the Cloud Firestore library for Python. Make sure to install the "google-cloud-firestore" module.
Run Code Online (Sandbox Code Playgroud)
我在这里收到此错误:
from firebase_admin import credentials, auth, firestore
我安装了firebase-admin模块:
pip install --upgrade -t libs firebase-admin
并运行应用
dev_appserver app.yaml
python google-app-engine firebase firebase-admin google-cloud-firestore
我正在尝试在 TeamCity 服务器中配置电子邮件通知。
\n\n\n\n以下是我尝试过的 2 个配置以及按下按钮时收到的相应错误Test connection以下是我尝试过的 2 个配置,以及当我按下下面的按钮
SMTP host: smtp.gmail.com\nSMTP port: 465\nSend email messages from: foobar@gmail.com\nSMTP login: foobar@gmail.com\nSMTP password: \xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\nSecure connection: SSL\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n\njavax.mail.MessagingException:无法连接到 SMTP 主机:\n smtp.gmail.com,端口:465;嵌套异常为:\n javax.net.ssl.SSLHandshakeException:\n sun.security.validator.ValidatorException:PKIX 路径构建失败:\n sun.security.provider.certpath.SunCertPathBuilderException:无法\n 找到有效的证书路径要求的目标
\n
SMTP host: smtp.gmail.com\nSMTP port: 587\nSend email messages from: foobar@gmail.com\nSMTP login: foobar@gmail.com\nSMTP password: \xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\nSecure connection: StartTSL\nRun Code Online (Sandbox Code Playgroud)\n\n\njavax.mail.MessagingException:无法将套接字转换为 TLS;
\n 嵌套异常为: javax.net.ssl.SSLHandshakeException:\n sun.security.validator.ValidatorException: PKIX 路径构建失败:\n …
首先,看看这个样本:
var calculate = function(callback) {
// calculating...
callback(5);
}
var parent = function() {
var x = 0;
var calculatedValue = calculate(function(output) {
return output; // return #1
x = output;
});
return x; // return #2
return calculatedValue; // return #3
}
Run Code Online (Sandbox Code Playgroud)
我的目标是在calculate函数内“计算”一个值,并且该值必须由parent函数返回。
为了实现这一点,我应该在哪里放置 return 语句,我应该用它返回什么?
我尝试了 3 种情况:
return #1
这里的output值是由callback函数返回的,而不是parent函数,所以 parent 返回 undefined。
return #2
这里x的值是在执行callback函数之前返回的,所以parent返回0。
return #3+return #1
在这里,我试图返回output从 …
我试图在我的 React 应用程序中包含一个 google place 自动完成输入框。
我已按照此处的指南放置<input>文本字段,并初始化搜索框,如下所示:
export default class MySearch extends class Component {
...
componentDidMount() {
var defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(-33.8902, 151.1759),
new google.maps.LatLng(-33.8474, 151.2631));
var input = document.getElementById('searchTextField');
var searchBox = new google.maps.places.SearchBox(input, {
bounds: defaultBounds
});
}
render() {
return (
...
<input id="searchTextField"
type="text"
className="form-control"
placeholder="Search for a location"
/>
);
}
}
Run Code Online (Sandbox Code Playgroud)
但我没有看到文本字段中出现任何建议。
我检查了“网络”选项卡,以查看在我键入时 API 请求是否被命中,并且当我键入时,我不仅看到请求,还看到来自 API 的响应,以及基于我的搜索词的匹配位置。
我不知道为什么收到的建议没有显示在我的输入框下方的下拉建议列表中。
提前致谢 :)
PS:我已将文本框放置在引导模式内。当我将完全相同的文本框放置在引导模式之外时,它的工作就像微风一样。
知道为什么文本框在模式内不显示建议吗?