小编use*_*619的帖子

要求没有定义

我正在构建一个新的React应用程序,但得到以下错误 - "require is not defined"

你好,world.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Hello React!</title>
    <script src="react/react.js"></script>
    <script src="react/react-dom.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script> 
  </head>
  <body>
    <div id="example"></div>
    <script type="text/babel" src="hello-world.js">
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

你好,world.js

import React from 'react';
import ReactDOM from 'react-dom';

import App from './App.jsx';

ReactDOM.render(
        <App />,
        document.getElementById('example')
      );
Run Code Online (Sandbox Code Playgroud)

App.jsx

import React from 'react';

class App extends React.Component {
   render() {
      return (
         <div>
            Hello World!!!
         </div>
      );
   }
}

export default App;
Run Code Online (Sandbox Code Playgroud)

我从我的客户端运行它,并没有运行任何Web服务器.

我试图包括http://requirejs.org/docs/release/2.2.0/minified/require.js, 但它给出了完全不同的错误.

requirejs reactjs

24
推荐指数
2
解决办法
4万
查看次数

高山包py-pip缺失

我试图使用Docker compose文件在我的alpine中安装python pip但是得到以下错误.

ERROR: unsatisfiable constraints:
  py-pip (missing):
    required by: world[py-pip]
ERROR: Service 'web' failed to build: The command '/bin/sh -c apk add py-pip' returned a non-zero code: 1
Run Code Online (Sandbox Code Playgroud)

docker dockerfile alpine-linux

22
推荐指数
6
解决办法
2万
查看次数

如何将脚本参数传递给pdb(Python)?

我有python脚本(ala#!/ usr/bin/python),我想用pdb调试它.如何将参数传递给脚本?

我有一个python脚本,并希望用pdb调试它.有没有办法可以将参数传递给脚本?

python debugging arguments pdb

19
推荐指数
1
解决办法
9356
查看次数

Maven Build和Maven安装之间的区别

我在Eclipse中使用Maven,当我尝试构建项目时,我看到以下选项:

  1. 建立
  2. 清洁
  3. 产生的来源
  4. 安装

Build和install之间有什么区别?如果构建可以配置为执行不同的目标,如"安装"......为什么我们需要单独的项目?

maven

17
推荐指数
1
解决办法
2万
查看次数

Python迭代非序列

我有这段代码创建一个笔记并添加到笔记本中.当我运行这个时,我得到一个非序列错误的迭代.

import datetime
class Note:
    def __init__(self, memo, tags):
        self.memo = memo
        self.tags = tags
        self.creation_date = datetime.date.today()

def __str__(self):
    return 'Memo={0}, Tag={1}'.format(self.memo, self.tags)


class NoteBook:
     def __init__(self):
        self.notes = []

     def add_note(self,memo,tags):
        self.notes.append(Note(memo,tags))

if __name__ == "__main__":
    firstnote = Note('This is my first memo','example')
    print(firstnote)
    Notes = NoteBook()
    Notes.add_note('Added thru notes','example-1')
    Notes.add_note('Added thru notes','example-2')
    for note in Notes:
        print(note.memo)
Run Code Online (Sandbox Code Playgroud)

错误:

C:\Python27\Basics\OOP\formytesting>python notebook.py  
Memo=This is my first memo, Tag=example  
Traceback (most recent call last):  
  File "notebook.py", line 27, in …

python

16
推荐指数
2
解决办法
5万
查看次数

配置Django-rest

我试图在Windows机器上设置DJango restframework,当我运行代码时出现以下错误,

完成的步骤.

  1. 从github下载的rest-framework和其他实用程序
  2. 使用easy_install我安装了所有软件包.

    这是确认消息,

    C:\ Python27\Scripts> easy_install django-rest搜索django-rest最佳匹配:django-rest 0.0.1处理django_rest-0.0.1-py2.7.egg django-rest 0.0.1已经是easy的活动版本了-install.pth

    使用c:\​​ python27\lib\site-packages\django_rest-0.0.1-py2.7.egg处理django-rest的依赖关系django-rest的已完成处理依赖关系

  3. 创建了一个新项目firstwebservice,它创建了所有文件.

  4. 编辑settings.py文件并包含django rest,如下所示,

    INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'rest_framework',
        # Uncomment the next line to enable the admin:
        # 'django.contrib.admin',
        # Uncomment the next line to enable admin documentation:
        # 'django.contrib.admindocs',
    )
    
    Run Code Online (Sandbox Code Playgroud)
  5. 跑完项目

    Error:-No module named rest_framework...
    
    Run Code Online (Sandbox Code Playgroud)

django django-rest-framework

15
推荐指数
1
解决办法
2万
查看次数

FileUploadBase $ SizeLimitExceededException apache tomcat

我试图从JSP文件上传文件,我在catalina.out中收到以下错误.正如许多博客中所指出的,我在webapps/manager/WEB-INF/web.xml下增加了max-file-size,但我仍然遇到同样的问题......我应该在哪里增加它来解决这个错误?

<multipart-config>
      <!-- 50MB max -->
      <max-file-size>5242880000000</max-file-size>
      <max-request-size>5242880000000</max-request-size>
      <file-size-threshold>0</file-size-threshold>
    </multipart-config>

org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (341297) exceeds the configured maximum (51200)
Run Code Online (Sandbox Code Playgroud)

tomcat tomcat7

14
推荐指数
3
解决办法
4万
查看次数

模拟 okhttp 响应

我有下面的方法,它执行 GET 请求 3 次,直到它成功。

模拟这种方法的更好方法是什么?我想模拟和测试 status_code 401、状态码 500 并想测试该方法是否执行三次。

在 python 中,我们有https://github.com/getsentry/responses直接模拟请求,所以很容易测试这些方法。

Java中是否有任何等效的东西。

@Override
    public <T> UResponse<T> get(Request request, JSONUnmarshaler<T> unmarshaller, Gson gson) throws UException {
        int status_code = 0;
        String next = null;
        String rawJSON = null;
        JsonElement jsonelement = null;
        Boolean retry = true;
        try {
            int attempts = 3;
            while ((attempts >= 0)  && (retry) && status_code != 200){
                Response response = this.client.newCall(request).execute();

                rawJSON = response.body().string();

                jsonelement = gson.fromJson(rawJSON, JsonElement.class);

                next = gson.fromJson(jsonelement.getAsJsonObject().get("next"), String.class); …
Run Code Online (Sandbox Code Playgroud)

java exception mockito okhttp

14
推荐指数
2
解决办法
1万
查看次数

比较sqlserver中的2个浮点值

variable-field1在2 tables-table1&中有一个浮动table2.当我查询表格并检查字段的值时,两者看起来都相同,但是当我发现它们的差异时,它会产生差异而不是零.

Field1(Table1) value---84.4660194174757
Field2(Table2) value---84.4660194174757

Differnce---1.4210854715202E-14
Run Code Online (Sandbox Code Playgroud)

为什么我会遇到这个问题?

sql-server

13
推荐指数
1
解决办法
2万
查看次数

uwsgi http很模糊

我试图在uwsgi上运行Django应用程序,但得到以下错误.

uwsgi --http :8000 --home /home/cuser/.virtualenvs/vq --chdir /var/www/sid/sid -w wsgi.py

uwsgi: option '--http' is ambiguous
getopt_long() error
Run Code Online (Sandbox Code Playgroud)

当我从-http更改为--socket时,它可以工作,但它再次说 - 家是模棱两可的

python django nginx uwsgi

13
推荐指数
2
解决办法
6996
查看次数