小编Ser*_*rge的帖子

gulp:uglify和sourcemaps

我正在使用gulp.

我想有一个或多个JS文件(比如说jQuery)将它们组合在一起,缩小它,然后将它写入分发文件夹.

我是这样做的:

minifyJS(['/js/myModule.file1.js',
          '/js/myModule.file2.js'], '/dist/js', 'myModule')
Run Code Online (Sandbox Code Playgroud)

功能:

function minifyJS(sourceFiles, destinationFolder, filenameRoot) {
    return gulp.src(sourceFiles)
        .pipe(plumber())

        // .pipe(sourcemaps.init()) here ???
        .pipe(concat(filenameRoot + '.js'))
        .pipe(sourcemaps.init()) // or here ???

        .pipe(gulp.dest(destinationFolder)) // save .js
        .pipe(uglify({ preserveComments: 'license' }))
        .pipe(rename({ extname: '.min.js' }))
        .pipe(gulp.dest(destinationFolder)) // save .min.js
        .pipe(sourcemaps.write('maps'))
        .pipe(gulp.dest(destinationFolder)) // save .map
}
Run Code Online (Sandbox Code Playgroud)

我不确定的是sourcemaps.init()位置......

我应该创建多个(在我的情况下是2个)地图文件(如果浏览器支持那么会很好)或只创建一个(/maps/myModule.map)?

javascript mapping gulp gulp-sourcemaps

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

在 C++ 中将 int 作为 bool 参数传递

有人可以解释一下这段代码中发生了什么:

这里的例子: https : //ideone.com/1cFb4N

#include <iostream>

using namespace std;

class toto
{
public:
    bool b;
    toto(bool x)
    {
        cout<< "constructor bool:" << (x ? "true": "false")<<endl;
        b = x;
    }
    ~toto() {}
};

int main()
{
    toto t = new toto(0);
    cout << "t.b is " << (t.b ? "true": "false")<<endl;
    t = new toto(false);
    cout << "t.b is " << (t.b ? "true": "false")<<endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

constructor bool:false
constructor bool:true
t.b is true
constructor bool:false
constructor …
Run Code Online (Sandbox Code Playgroud)

c++ constructor pointers boolean implicit-conversion

43
推荐指数
3
解决办法
4420
查看次数

将复选框值传递给angular的ng-click

有没有办法传递给角度指令ng-单击相关输入的值?

换句话说,应该替换this.value以下内容:

<input type="checkbox" id="cb1" ng-click="checkAll(this.value)" />
Run Code Online (Sandbox Code Playgroud)

PS.我不想要一个替代值的替代方法,我只是想知道是否可以将输入的值作为参数传递给angular函数.

javascript checkbox angularjs angularjs-ng-click

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

跳过JavaScript函数中的参数

我有这样的功能:

function foo(a, b, c, d, e, f) {
}
Run Code Online (Sandbox Code Playgroud)

为了仅使用f参数调用此函数,我知道我应该这样做:

foo(undefined, undefined, undefined, undefined, undefined, theFValue);
Run Code Online (Sandbox Code Playgroud)

是否有一个不那么冗长的方法来做到这一点?

解决方案:
我选择了一些建议的解决方案(不使用辅助第三功能)

// zero - ideal one, actually not possible(?!)
foo(f: fValue);

// one - asks a "strange" declaration
var _ = undefined;
foo(_, _, _, _, _, fValue);

// two - asks the {} to be used instead of a 'natural' list of args
//     - users should be aware about the internal structure of args obj
// …
Run Code Online (Sandbox Code Playgroud)

javascript

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

我应该手动安装所有对等依赖项以删除 npm 警告吗?

我通过npm几个角度包安装,我有这个警告:

@angular/compiler-cli@7.2.5 requires a peer of typescript@>=3.1.1 <3.3 
                                                                    but none is installed. 
You must install peer dependencies yourself.
Run Code Online (Sandbox Code Playgroud)

a) 对等依赖和公正依赖之间有什么区别?
b) 我现在应该安装什么来修复警告?

我的意思是,假设我安装了一个我知道的包“P”,但是这个 P 需要 X、Y 和 Z。我应该手动安装它们吗?好像不是很爽。。。

实际上,我安装了Angular,但是Angular需要compiler-clr和最新的需要typescript

当我看到这个警告时,我安装了npm install typescript它给我安装了版本typescript@3.3.3,但是这个 ***compiler-clr需要 typescript@ <3.3,我现在该怎么办?

3.3对于这种类型的所有警告,我是否应该分析之前发布的打字稿版本等等?

npm typescript npm-install angular

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

卸载Visual F#

我使用Visual Studio 2013,它有一个很好的功能来通知和安装所有扩展更新.

所以,这非常好,但我有时会收到安装我从未使用的功能的更新的请求.

例如,它建议我安装Visual F#3.1的更新

有没有办法彻底删除这个F#?我尝试从扩展管理器卸载,它将我发送到"添加和删除程序",但是有任何程序包含"F#".

如何进行?

.net visual-studio visual-studio-extensions visual-studio-2013

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

执行策略“SqlServerRetryingExecutionStrategy”不支持用户启动的事务

我有一个 ASP.NET Core 5 MVC Web 应用程序,使用 Entity Framework Core 5。

我们实现 Web 组件,例如网格或电子表格(我们与 Telerik 合作)。当我在组件中进行一些更改,然后尝试保存更改时,组件会调用 my ApplicationDbContext.SaveChanges. 然后我收到以下错误:

System.InvalidOperationException:配置的执行策略“SqlServerRetryingExecutionStrategy”不支持用户启动的事务。使用“DbContext.Database.CreateExecutionStrategy()”返回的执行策略将事务中的所有操作作为可重试单元执行。

在此输入图像描述

这是我ConfigureServices用于 DBContext 的方法:

public static void AddDbContext(this IServiceCollection services, string connectionString) =>
    services.AddDbContext<ApplicationDbContext>(options =>
    {
        options.UseSqlServer(connectionString,
            providerOptions =>
            {
                providerOptions
                    .EnableRetryOnFailure(
                        maxRetryCount: 5, 
                        maxRetryDelay: TimeSpan.FromSeconds(30),
                        errorNumbersToAdd: null)
                    .UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery);
            });
        options.EnableSensitiveDataLogging();
        options.ConfigureWarnings(w => w.Throw(RelationalEventId.MultipleCollectionIncludeWarning));
    });
Run Code Online (Sandbox Code Playgroud)

该错误不会系统地发生。当然,当我尝试将多个元素保存到数据库时。而且当只有一个元素时也是如此。当我以经典形式逐一编辑或相同元素时不会发生,只有当它发生在多个对象场景(网格或电子表格)中时...

StackTrace 会是这样的: 在此输入图像描述

作为示例,我给出了一个方法,允许将Entreprise对象从电子表格提交到数据库,以便使用CreateExecutionStrategy方法:

public ActionResult Data_Source_Entreprises_Submit(SpreadsheetSubmitViewModel model)
{
    var result = new SpreadsheetSubmitViewModel()
    {
        Created = new …
Run Code Online (Sandbox Code Playgroud)

c# telerik entity-framework-core asp.net-core asp.net-core-5.0

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

在Visual Studio中粘贴矩形块

有没有办法在Visual Studio中粘贴矩形块(2017年,例如).

在此输入图像描述

我现在唯一可以做的就是首先粘贴值,然后从左到右"环绕"值列,如下所示:

在此输入图像描述

text-editor visual-studio visual-studio-2017

12
推荐指数
1
解决办法
3917
查看次数

跟踪当前活动页面,或如何在视图中获取控制器和操作名称

我是ASP.NET Core的新手.我有一个导航菜单,我想跟踪活动项目.我的想法是使用动作和控制器名称作为导航键:

在此输入图像描述

问题是我不知道如何在_Layout.cshtml视图中获取动作和控制器名称...

我试过了,ViewContext.ActionDescriptor.DisplayName但它渲染了这样的东西MyApp.Controllers.RecordsController.Index (MyApp)

我宁愿更喜欢这样的东西:

<script>$("li#@(Controller.Name)-@(Action.Name)")).addClass("active");</script>
Run Code Online (Sandbox Code Playgroud)

razor asp.net-core

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

如何通过ASP.NET Core中的链接进行发布

我尝试通过链接发布到SetLanguage操作,但是不确定如何完成以下代码:

<form id="selectLanguage" asp-controller="Home" asp-action="SetLanguage" asp-route-returnUrl="@Context.Request.Path" method="post" role="form">
    @foreach (var culture in cultures) {
        <div>                
            <a href="?culture=@culture.Name">@culture.Name</a>
        </div>
    }
 </form>
Run Code Online (Sandbox Code Playgroud)

我应该使用form还是有直接方法culture : 'EN'通过例如发送带有参数的POST ?

是否@Url.Action(action: "SetLanguage", controller:"Home", values: new { culture = culture.Name }, protocol:"POST")做的工作?

我的控制器代码是

[HttpPost]
public IActionResult SetLanguage(string culture, string returnUrl)
{
    Response.Cookies.Append(
        CookieRequestCultureProvider.DefaultCookieName,
        CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture)),
        new CookieOptions { Expires = DateTimeOffset.UtcNow.AddYears(1) }
    );

    return LocalRedirect(returnUrl);
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-core asp.net-core-1.1

9
推荐指数
1
解决办法
7966
查看次数