我正在玩React和ES6使用babel和webpack.我想在不同的文件中构建几个组件,导入一个文件并将它们捆绑在一起webpack
假设我有几个这样的组件:
我-navbar.jsx
import React from 'react';
import Navbar from 'react-bootstrap/lib/Navbar';
export class MyNavbar extends React.Component {
render(){
return (
<Navbar className="navbar-dark" fluid>
...
</Navbar>
);
}
}
Run Code Online (Sandbox Code Playgroud)
主page.jsx
import React from 'react';
import ReactDOM from 'react-dom';
import MyNavbar from './comp/my-navbar.jsx';
export class MyPage extends React.Component{
render(){
return(
<MyNavbar />
...
);
}
}
ReactDOM.render(
<MyPage />,
document.getElementById('container')
);
Run Code Online (Sandbox Code Playgroud)
使用webpack并按照他们的教程,我有main.js:
import MyPage from './main-page.jsx';
Run Code Online (Sandbox Code Playgroud)
构建项目并运行它后,我在浏览器控制台中收到以下错误:
Error: Invariant Violation: Element …Run Code Online (Sandbox Code Playgroud) 我正在使用react和webpack作为我的模块捆绑器编写Web应用程序.jsx到目前为止,我的代码非常轻,整个文件夹的大小为25 kb.
我bundle.js创建的webpack是2.2 mb.在使用-p标志运行优化之后,它将捆绑包减少到700kb,这仍然非常大.
我查看了该react.min.js文件,其大小为130kb.
webpack是否可能产生如此大的文件,或者我做错了什么?
webpack.config.js
var path = require('path');
var webpack = require('webpack');
module.exports = {
entry: './public/components/main.jsx',
output: {
path: __dirname + "/public",
filename: 'bundle.js'
},
module: {
loaders: [{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
}, {
test: /\.css$/,
loader: "style!css"
}]
}
};
Run Code Online (Sandbox Code Playgroud)
编辑
的package.json:
{
"name": "XChange",
"version": "0.0.0",
"private": true,
"scripts": {
"start": …Run Code Online (Sandbox Code Playgroud) 我正在开发一个与我编写的RESTful Web服务进行通信的Android应用程序.使用Volleyfor GET方法非常简单,但我不能指责POST方法.
我想在POST请求String正文中发送请求,并检索Web服务的原始响应(如200 ok,500 server error).
所有我能找到的是StringRequest不允许发送数据(正文),并且它限制我接收解析的String响应.我也遇到了JsonObjectRequest接受数据(正文)但检索解析后的JSONObject响应.
我决定编写自己的实现,但是我找不到从Web服务接收原始响应的方法.我该怎么做?
我正在学习,GraphQL所以我建了一个小项目.假设我有2个型号,User并且Comment.
const Comment = Model.define('Comment', {
content: {
type: DataType.TEXT,
allowNull: false,
validate: {
notEmpty: true,
},
},
});
const User = Model.define('User', {
name: {
type: DataType.STRING,
allowNull: false,
validate: {
notEmpty: true,
},
},
phone: DataType.STRING,
picture: DataType.STRING,
});
Run Code Online (Sandbox Code Playgroud)
关系是1:很多,用户可以有很多评论.
我已经构建了这样的架构:
const UserType = new GraphQLObjectType({
name: 'User',
fields: () => ({
id: {
type: GraphQLString
},
name: {
type: GraphQLString
},
phone: {
type: GraphQLString
},
comments: {
type: new GraphQLList(CommentType), …Run Code Online (Sandbox Code Playgroud) 我试图禁用日志输出mongo-java-driver-3.0.0.
我已经尝试在加载mongo驱动程序之前在应用程序的开头设置它们,但它没有帮助.
// Enable MongoDB logging in general
System.setProperty("DEBUG.MONGO", "false");
// Enable DB operation tracing
System.setProperty("DB.TRACE", "false");
Run Code Online (Sandbox Code Playgroud)
我得到这种日志:
11:01:15.406 [pool-1-thread-1] DEBUG org.mongodb.driver.protocol.query - Sending query of namespace susudev.Players on connection [connectionId{localValue:2, serverValue:28}] to server localhost:27017
11:01:15.406 [pool-1-thread-1] DEBUG org.mongodb.driver.protocol.query - Query completed
11:01:25.174 [cluster-ClusterId{value='554dbecb1b554f11e86c3a69', description='null'}-localhost:27017] DEBUG org.mongodb.driver.cluster - Checking status of localhost:27017
11:01:25.177 [cluster-ClusterId{value='554dbecb1b554f11e86c3a69', description='null'}-localhost:27017] DEBUG org.mongodb.driver.cluster - Updating cluster description to {type=STANDALONE, servers=[{address=localhost:27017, type=STANDALONE, roundTripTime=0.6 ms, state=CONNECTED}]
Run Code Online (Sandbox Code Playgroud)
所以我的控制台完全包含mongo日志,我无法阅读任何内容.
我正在尝试创建一个Kafka集群来向远程控制发送消息.我按照此处的描述配置了所有内容.我在一Linux red hat台机器上运行它,它使用shell工作正常.在quick start我的Windows机器上编写教程中描述的java代码后,我收到以下错误:
...
DEBUG kafka.client.ClientUtils$ - Successfully fetched metadata for 1 topic(s) Set(example)
...
ERROR kafka.producer.SyncProducer - Producer connection to cldExampleKafka.domain:80 unsuccessful
java.nio.channels.UnresolvedAddressException
...
at kafka.producer.async.ProducerSendThread.run(ProducerSendThread.scala:44)
...
WARN kafka.producer.async.DefaultEventHandler - Failed to send producer request with correlation id 2 to broker 0 with data for patitions [ati,0]
java.nio.channels.UnresolvedAddressException
...
kafka.common.FailedToSendMessageException: Failed to send message after 3 tries.
Run Code Online (Sandbox Code Playgroud)
我也尝试在不同的Linux机器上运行jar,但仍然收到同样的错误.
localhost在安装kafka的机器中将地址更改为Java代码并将其作为jar运行.
我相信配置的东西,但我找不到它.
我们正在尝试插入一个包含当前日期的文档作为其字段.我们使用eclipse插件为mongodb编写java.我们想要执行Date()mongo 的命令来从mongo而不是从java获取日期.
我该如何执行这个mongo查询?
db.example.insert({"date":new Date()})
Run Code Online (Sandbox Code Playgroud)
我在预览问题中发现了这个问题,但答案没有帮助
我正在使用react-bootstrap我的网站样式.我想添加Navbar所有元素镜像到右边的位置.
export default class XNavbar extends React.Component {
render() {
return (
<Navbar inverse fluid >
<Navbar.Header>
<Navbar.Brand>
<a href="#">Brand</a>
</Navbar.Brand>
<Navbar.Toggle />
</Navbar.Header>
<Navbar.Collapse>
<Nav>
<NavItem eventKey={1} href="#">Hello</NavItem>
<NavItem eventKey={2} href="#">World</NavItem>
</Nav>
</Navbar.Collapse>
</Navbar>
)}
}
Run Code Online (Sandbox Code Playgroud)
但我真正希望它是什么
[ World Hello Brand ]
Run Code Online (Sandbox Code Playgroud)
我试着用pullRight的<Navbar,但没有奏效.我也补充说<html dir="rtl">,但这也没有帮助.我该怎么做?
我正在编写一个使用mongo作为其数据库的应用程序.我想打印连接到db的客户端,例如,打印他们的ip.我怎样才能获得这些信息?
我试过用
db.serverStatus().connections
Run Code Online (Sandbox Code Playgroud)
但它给了我访问我的数据库的计算机数量.
我学习GraphQL,我得到一点从具体问题有不同的实现书写时感到困惑fields的GraphQLObjectType。
这两种实现有什么区别?
1.
var schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'RootQueryType',
fields: { // as object
echo: {
type: GraphQLString,
args: {
email: { type: EmailType }
},
resolve: (root, {email}) => {
return email;
}
}
}
})
});
Run Code Online (Sandbox Code Playgroud)
2.
var ComplicatedArgs = new GraphQLObjectType({
name: 'ComplicatedArgs',
fields: () => ({ // as function
complexArgField: {
type: GraphQLString,
args: {
complexArg: { type: ComplexInput }
},
}
}),
});
Run Code Online (Sandbox Code Playgroud) java ×3
mongodb ×3
reactjs ×3
graphql ×2
webpack ×2
android ×1
apache-kafka ×1
database ×1
eclipse ×1
ecmascript-6 ×1
graphql-js ×1
html ×1
linux ×1
logging ×1
node.js ×1
rest ×1
sequelize.js ×1
sql ×1
web-services ×1