小编Sia*_*ash的帖子

webpackJsonp未定义

代码

这是我的webpack.babel.js

入境部分:

entry: {
   vendor: [
       "react",
       "react-dom"
    ]
}

// ??????(??????????)
let files = glob.sync('./src/**/index.js'),
    newEntries = files.reduce(function (memo , file) {
        let name = /.*\/(.*?)\/index\.js/.exec(file)[1];

        memo[name] = entry(name);

        return memo;
    }, {});

config.entry = Object.assign({} , config.entry , newEntries);

function entry(name) {
    return './src/js/' + name + '/index.js';
}
Run Code Online (Sandbox Code Playgroud)

输出部分:

output: {
    path: path.join(__dirname,"/dist/js/"),
    filename: "[name].js"
},
Run Code Online (Sandbox Code Playgroud)

模块部分:

 module: {

        // ??js??? ?? ?es5 ?? ?????? js ?? 
        loaders: [{
            test: /\.js$/,
            exclude: /node_modules/,
            loader: 'babel',
            query: …
Run Code Online (Sandbox Code Playgroud)

reactjs webpack

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

如何解决 GitLab 上的冲突?

我最近与之合作git,有这样一个问题。我提出了一个merge从当前branchmaster. 并收到了这样一条消息:

在此处输入图片说明

允许这样做的选项是什么,以便网站上出现按钮以接受merge?如果我进行本地合并,它会自动关闭,但我不需要。有什么选择吗?

git git-merge gitlab

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

如何仅在密钥存在时通过密钥对ConcurrentDictionary中的值进行原子更新

ConcurrentDictionary.TryUpdate方法需要将comparisonValue与具有指定键的元素的值进行比较.但如果我尝试做这样的事情:

if (!_store.TryGetValue(book.Id, out Book existing))
{
    throw new KeyNotFoundException();
}

if (!_store.TryUpdate(book.Id, book, existing))
{
    throw new Exception("Unable to update the book");
}
Run Code Online (Sandbox Code Playgroud)

当多个线程同时更新一本书时,它会抛出一个异常,因为existingbook在另一个线程中被更改了.

我不能使用索引器,因为它添加了书,如果它不存在,我不能检查键是否存在,因为它也不会原子.

我改变了我的代码:

while (true)
{
    if (!_store.TryGetValue(book.Id, out Book existing))
    {
        throw new KeyNotFoundException();
    }

    if (_store.TryUpdate(book.Id, book, existing))
    {
        break;
    }
}
Run Code Online (Sandbox Code Playgroud)

但我担心无限循环.

但是如果我在Update和Delete方法上使用锁定,我将失去使用ConcurrentDictionary的优势.

解决问题的正确方法是什么?

c# collections dictionary concurrentdictionary

7
推荐指数
1
解决办法
418
查看次数

React + ASP.NET.Core:所请求的资源上不存在“ Access-Control-Allow-Origin”标头

实际上,这不是重复的帖子,我知道在stackoverflow社区中多次问过的标题的一部分,我阅读了所有帖子和答案,但是我认为我使用的问题和技术是不同的。

首先,我应该提到的ASP.NET Core WEB/API是我的后端应用程序,Reactjs也是我的前端应用程序。

我阅读了一下CORS,发现必须CORSASP.NETApp 'Access-Control-Allow-Origin':'*'上启用并放入 请求的标头,但是在调用api时仍然出现以下错误:

所请求的资源上没有“ Access-Control-Allow-Origin”标头。因此,不允许访问源' http:// localhost:8080 '。该响应的HTTP状态代码为500。如果不透明响应满足您的需求,请将请求的模式设置为“ no-cors”,以在禁用CORS的情况下获取资源。

这是我的Startup.cs代码与CORS

public void ConfigureServices(IServiceCollection services)
{

    // other lines of code
    services.AddCors(options =>
    {
        options.AddPolicy("AllowAll",
            builder =>
            {
                builder
                .AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            });
    });

    services.Configure<MvcOptions>(options =>
    {
        options.Filters.Add(new CorsAuthorizationFilterFactory("AllowAll"));
    });
    // other lines of code
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    loggerFactory.AddConsole(Configuration.GetSection("Logging"));
    loggerFactory.AddDebug();
    app.UseCors("AllowAll"); …
Run Code Online (Sandbox Code Playgroud)

c# cors reactjs .net-core asp.net-core

7
推荐指数
3
解决办法
4103
查看次数

React-JS/react-router-dom中的路由问题

react-router通过在命令提示符窗口中运行以下代码片段来安装我的项目:

npm install react-router

我发现react-router安装成功,因为安装时没有错误,输出也是:

  • react-router@4.3.1在19.53s更新了1个包

根据教程,我设置我的Index.js,如下面的代码:

ReactDOM.render((
   <Router history = {browserHistory}>
      <Route path = "/" component = {App}>
         <IndexRoute component = {Home} />
         <Route path = "home" component = {Home} />
         <Route path = "about" component = {About} />
         <Route path = "contact" component = {Contact} />
      </Route>
   </Router>
), document.getElementById('app'))
Run Code Online (Sandbox Code Playgroud)

现在,当我想编译/构建我的应用程序时,会发生以下错误:

./src/index.js
  Line 14:  'Router' is not defined          react/jsx-no-undef
  Line 14:  'browserHistory' is not defined  no-undef
  Line 15:  'Route' is not defined …
Run Code Online (Sandbox Code Playgroud)

routing reactjs react-router react-router-v4 react-router-dom

5
推荐指数
1
解决办法
1657
查看次数

如何更改 ac# 控制台应用程序的入口点?

我想知道是否可以将 .NET 控制台应用程序入口点从以下示例中的方法更改Main为:Main2

class Program
{ 
    static void Main(string[] args)
    {
        Console.WriteLine("Main");
    }

    //desired entry point
    static void Main2(string[] args)
    {
        Console.WriteLine("Main2");
    }
}
Run Code Online (Sandbox Code Playgroud)

我调查了这两个的 IL 代码。这是Main方法:

  .method private hidebysig static void 
    Main(
      string[] args
    ) cil managed 
  {
    .entrypoint
    .maxstack 8

    // other instructions

  } // end of method Program::Main
Run Code Online (Sandbox Code Playgroud)

以及Main2方法:

.method private hidebysig static void 
    Main2(
      string[] args
    ) cil managed 
  {
    .maxstack 8

    //other instructions
  } // end of method …
Run Code Online (Sandbox Code Playgroud)

.net c# clr cil csc

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

是否可以使用 ML.NET Preview (0.6) 来表征 C# 集合?

可以说我有一个复杂的类型:

class Policy
{
    string Name { get; set; }
    DateTime InceptionDate { get; set; }
    DateTime ExpirationDate { get; set; }
    List<Location> Locations { get; set; }
}

class Location
{
    string Street { get; set; }
    string City { get; set; }
    string State { get; set; }
    string PostalCode { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

如何将 的集合转换Locations为特征列以供 ML.NET 理解?

c# collections ml.net

5
推荐指数
1
解决办法
2082
查看次数

Asp.net core - invoke method() 不在中间件中调用

我熟悉中间件概念,并且在我的项目中实现了许多中间件。我还阅读了Microsoft 文档中的ASP.NET Core 中间件文档。但这一次我遇到了令人困惑的问题,实际上我编写了一个简单的中间件来为每个请求写入日志。

这是我的中间件类:

public class LoggerMiddleware
{
    private readonly RequestDelegate _next;

    public LoggerMiddleware(RequestDelegate next)
    {
        _next = next;
    }

    public async Task Invoke(HttpContext httpContext, LogDbContext dbContext)
    {
        var logInfo = await Logger.InitiateLogging(httpContext, dbContext);
        try
        {
            await _next(httpContext);
        }
        catch (Exception ex)
        {
            await Logger.AddException(httpContext, ex, true);
        }
        finally
        {
            await Logger.PersistLog(logInfo, httpContext);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我声明了一个扩展方法:

public static class LoggingMiddlewareExtensions
{
    public static IApplicationBuilder UseLogger(this IApplicationBuilder builder)
    {
        return builder.UseMiddleware<LoggerMiddleware>();
    }
}
Run Code Online (Sandbox Code Playgroud)

最后我在 Startup.cs 上调用了UseLogger …

c# logging middleware .net-core asp.net-core

5
推荐指数
1
解决办法
2731
查看次数

如何在不使用 Visual Studio 的情况下编辑 rdlc 报告

我现在正在使用Sql Server Management StudioVisual Studio C#。我创建了一个Stored Procedure从数据库中的表中检索数据。使用结果dataset,我rdlc使用 Visual Studio 报告设计器创建了一个报告。

我将在不同位置的不同系统中安装此软件(我正在开发的软件)。问题是,用户可能想要更改报告的设计(仅设计,而不是dataset),而我无法在所有这些系统上安装 Visual Studio。所以,我想知道有没有什么工具可以用来只改变rldc报表的设计,体积更小,安装方便(与visual studio相比)

c# stored-procedures report rdlc visual-studio

5
推荐指数
0
解决办法
2396
查看次数

如何在LINQ查询中放入条件WHERE子句

我正在尝试在哪里做condition对,我要执行WHERE其他,否则。

var condition = true;

var mast = new List<Master>
{
    new Master{Id = 2, Prop1 = "Default", Prop2 = "Data", Prop3 = 11},
    new Master{Id = 3, Prop1 = "Some", Prop2 = "TestData", Prop3 = 11},
    new Master{Id = 4, Prop1 = "Some", Prop2 = "MoreData", Prop3 = 11},
};

var g = mast.Where(w=> condition ? (x => x.Prop1.ToLower() != "default" || x.Prop2.ToLower() != "data") : true = true).ToList();
Run Code Online (Sandbox Code Playgroud)

上面的代码给我错误,

无法确定条件表达式的类型,因为“ lambda表达式”和“ bool”之间没有隐式转换

c# linq lambda

5
推荐指数
1
解决办法
104
查看次数