【问题标题】:How to reference lodash in my dot net core project?如何在我的 dot net core 项目中引用 lodash?
【发布时间】:2019-09-19 16:15:29
【问题描述】:

如何在我的 dot net core 项目中引用 lodash。 我创建了一个新的 dot net core web 应用程序并使用 nuget 包管理器安装了 lodash。

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="BuildBundlerMinifier" Version="3.0.415" />
    <PackageReference Include="lodash" Version="4.17.11" />
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
    <PackageReference Include="newtonsoft.json" Version="12.0.2" />
  </ItemGroup>
  </Project>

我的问题是,既然我的 .csproj 文件中引用了 lodash,我该如何在我的应用程序中使用 lodash?

【问题讨论】:

标签: asp.net-core .net-core


【解决方案1】:

我认为您必须导入您感兴趣的名称空间并使用它。获取当前日期的示例

using System;
using Lodash.Net.Methods;

var loadDashDAte = new LodashDate();

// Gets the timestamp of the number of milliseconds that have elapsed since the Unix epoch (1 January 1970 00:00:00 UTC).

var currentDate = loadDashDate.Now();

Console.WriteLine(currentDate.ToString());

【讨论】:

    猜你喜欢
    • 2017-06-07
    • 1970-01-01
    • 1970-01-01
    • 2018-05-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-02
    • 1970-01-01
    • 2021-02-10
    相关资源
    最近更新 更多