我正在create-react-app和我一起工作并遇到了这个问题Home does not contain an export named Home.
这是我设置App.js文件的方式:
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { Home } from './layouts/Home'
class App extends Component {
render() {
return (
<div className="App">
Hello
<Home />
</div>
)
}
}
export default App;
Run Code Online (Sandbox Code Playgroud)
现在在我的layouts文件夹中我有Home.js文件.设置如下.
import React, { Component } from 'react';
class Home extends Component{
render(){
return(
<p className="App-intro">
Hello Man
</p>
)
} …Run Code Online (Sandbox Code Playgroud) 我试图在我的一个反应组件中导入一个图像文件.我有web包的项目设置
这是我的组件代码
import Diamond from '../../assets/linux_logo.jpg';
export class ItemCols extends Component {
render(){
return (
<div>
<section className="one-fourth" id="html">
<img src={Diamond} />
</section>
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的项目结构.
我按以下方式设置了我的webpack.config.js文件
{
test: /\.(jpg|png|svg)$/,
loader: 'url-loader',
options: {
limit: 25000,
},
},
{
test: /\.(jpg|png|svg)$/,
loader: 'file-loader',
options: {
name: '[path][name].[hash].[ext]',
},
},
Run Code Online (Sandbox Code Playgroud)
PS.我可以从任何其他远程源获取图像,但不能从本地保存的图像.JavaScript控制台也没有给我任何错误.请帮忙.我很反应,无法找到我做错了什么.
我最近开始使用rails 5开发REST API.我正在尝试通过API调用执行User粗体操作.我为用户设置了一个基本的设计.
在我的路线中我有这个:
Rails.application.routes.draw do
devise_for :users, :controllers => {sessions: 'sessions', registrations: 'registrations'}
end
Run Code Online (Sandbox Code Playgroud)
我创建了两个独立的控制器sessions_controller和registrations_controller来覆盖设计方法并使其接受JSON格式.
class RegistrationsController < Devise::RegistrationsController
respond_to :json
end
Run Code Online (Sandbox Code Playgroud)
和
class SessionsController < Devise::SessionsController
respond_to :json
end
Run Code Online (Sandbox Code Playgroud)
我正在尝试注册传递以下数据的用户:
{
user: {
email: me@gmail.com,
password: password,
password_confirmation: password
}
}
Run Code Online (Sandbox Code Playgroud)
我得到状态200.但在我的rails服务器中我收到以下错误:
Started POST "/users" for 23.233.9.94 at 2016-12-22 08:22:11 +0000
Processing by RegistrationsController#create as */*
Parameters: {"Payload: { \r\n user: {\r\n email: me@gmail.com,\r\n password: password,\r\n password_confirmation: password\r\n }\r\n}"=>"[FILTERED]"}
(0.2ms) begin transaction
(0.1ms) rollback transaction
Completed 200 OK …Run Code Online (Sandbox Code Playgroud) 我的代码如下.它的工作完美而间隔不是很大.但是每当我超过一百万时,程序就会停止.例如,对于区间2到2000000,素数之和应该是142913828922(从书的后面),而我的应用程序显示1179908154.有人可以指出我哪里出错了.
#include <iostream>
#include <math.h>
#define BELOW 2000000;
using namespace std;
bool isPrime(int num)
{
int i;
for (i = 2; i <= sqrt(num); i++) {
if (num % i == 0) {
return 0;
}
else {
;
}
}
}
int main()
{
long sum = 0;
for (int i = 2; i < BELOW i++) {
if (isPrime(i)) {
sum = sum + i;
printf("sum: %ld\n", sum);
}
}
cin.get();
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我试图在每次詹金斯重新启动时运行一项新工作。我想通过“init.groovy”脚本来做到这一点。例如,假设我重新启动詹金斯服务器,它将执行一个显示“Hello world”的作业。我必须从我的 init.groovy 脚本创建这个作业。
到目前为止我有这个代码
import jenkins.model.Jenkins
import org.jenkinsci.plugins.workflow.job.WorkflowJob
WorkflowJob job = Jenkins.instance.createProject(WorkflowJob, 'my-pipeline2')
Run Code Online (Sandbox Code Playgroud)
现在我不知道如何在不进入 GUI 的情况下配置这个作业实例。我想向其中添加管道脚本。就像回声“Hello world”一样。然后我想最终完成这项工作。我想通过这个 init.groovy 脚本来完成所有这些工作。我在互联网上找不到任何解决方案。因此,非常感谢任何帮助。谢谢
我正在使用递归来解决迷宫问题.我的矩阵看起来像这样
char maze[][] =
{
{'#','#','#','#','#','#','#','#','#','#','#'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'},
{'#','#','#','#',' ','#','#','#','#','#','#'},
{'#',' ',' ',' ',' ','#',' ',' ',' ',' ','X'},
{'#',' ',' ',' ',' ','#',' ',' ',' ',' ','#'},
{'#',' ','#','#','#','#','#','#',' ','#','#'},
{'#',' ',' ',' ',' ',' ',' ',' ',' ',' ','#'},
{'#','#','#','#','#','#','#','#','#','#','#'},
};
Run Code Online (Sandbox Code Playgroud)
这是更大矩阵的原型.我的求解递归方法看起来像这样
private void solve(int x, int y) {
// set everything to false
wasHere = new boolean[maze.length][maze[1].length];
correctPath = new boolean[maze.length][maze[1].length];
for (int i = 0; i < maze.length; …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的 React 组件中制作一个简单的 iframe 来显示谷歌地图位置。我目前正在像这样对 src 进行硬编码
this.state.features.map(function(school){
return(
<div>
{school.name}
<div>
<iframe frameBorder="0" style={{ width: "100%", height: "450"}}
src="https://www.google.com/maps/embed/v1/place?q=40.7127837,-74.0059413&key=AIzaSyCc3zoz5TZaG3w2oF7IeR-fhxNXi8uywNk">
</iframe>
</div>
</div>
)
})
Run Code Online (Sandbox Code Playgroud)
这似乎有效。但是我想使用反应变量传递 scr 所以我正在做这样的事情
const MY_API = AIzaSyCc3zoz5TZaG3w2oF7IeR-fhxNXi8uywNk
let _url = "https://www.google.com/maps/embed/v1/place?q=40.7127837,-74.0059413&key="+MY_API;
Run Code Online (Sandbox Code Playgroud)
然后像这样动态传递 src
<iframe frameBorder="0" style={{ width: "100%", height: "450"}}
src={_url}>
</iframe>
Run Code Online (Sandbox Code Playgroud)
但现在我收到以下错误
Google Maps API 服务器拒绝了您的请求。无效请求。意外参数“amp%3Bkey”
不确定错误消息是关于什么的。请帮忙。
我试图通过power-shell脚本安装证书.我正在使用Import-Certificatemicrosoft的power shell网站上的建议.这是我的代码
$script = {
$file = ( Get-ChildItem -Path C:\Users\Administrator\Desktop\newCert.cer )
$file | Import-Certificate -CertStoreLocation cert:\CurrentUser\Root
echo $file
}
invoke-command -Credential $clientCred -ComputerName $ClientIP -ScriptBlock $script
Run Code Online (Sandbox Code Playgroud)
所以我得到以下错误.
UI is not allowed in this operation
+ CategoryInfo : InvalidArgument: (:) [Import-Certificate], ArgumentException
Run Code Online (Sandbox Code Playgroud)
不知道哪里出错了.如果有人能指出我正确的方向,那将会非常有帮助.
我正在通过迭代(无递归)解决 N 皇后问题。我现在面临的问题是重复的解决方案。例如,4 x 4 板有 2 个解决方案,我正在打印 4 个解决方案,也就是说我两次找到相同的解决方案。
让我进入代码以获得更好的概述:
def solution(self):
queen_on_board = 0
for row in range(self.N):
for col in range(self.N):
self.board[row][col] = 'Q'
queen_on_board = queen_on_board + 1
print ("(row,col) : ", row, col)
squares_list = self.get_posible_safe_squares(row,col)
for square in squares_list:
for x,y in square.items():
if self.isTheQueenSafe(x,y):
self.board[x][y] = 'Q'
queen_on_board = queen_on_board + 1
print ("Queen on board", queen_on_board)
if queen_on_board == 4:
self.print_the_board()
self.reset_the_board()
queen_on_board = 0
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我正在检查每一行和列。这个特定的实现给了我 4 个相同的解决方案 2。
(row,col) : 0 …Run Code Online (Sandbox Code Playgroud) 我试图在ajax回调从REST api接收数据后设置组件的状态.这是我的组件构造函数的代码
constructor(props) {
super(props);
this.state = { posts: [] };
this.getPosts = this.getPosts.bind(this);
}
Run Code Online (Sandbox Code Playgroud)
然后我有一个componentDidMount看起来像下面的方法.
componentDidMount() {
this.getPosts();
}
Run Code Online (Sandbox Code Playgroud)
现在这是我的getPosts函数,我正在执行ajax请求.
getPosts = () => {
$.ajax({
type: 'get',
url: urlname,
success: function(data) {
this.setState( { posts: data } )
}
});
}
Run Code Online (Sandbox Code Playgroud)
我想要设置状态,但我收到以下错误.
this.setState is not a function
Run Code Online (Sandbox Code Playgroud)
不确定是什么导致了这一点.如果有人指出我正确的方向,那将是非常有帮助的.提前致谢.
javascript ×4
reactjs ×4
algorithm ×2
ajax ×1
api ×1
c++ ×1
devise ×1
ecmascript-6 ×1
google-maps ×1
groovy ×1
java ×1
jenkins ×1
jquery ×1
json ×1
matrix ×1
maze ×1
n-queens ×1
powershell ×1
python-3.x ×1
recursion ×1
rest ×1
ssl ×1
this ×1
webpack ×1