小编Nod*_*.JS的帖子

基础工具提示`没有$(document).foundation();`和`modernizr`

我正在尝试初始化基础工具提示而不初始化所有内容(即$(document).foundation())并且我在这个简单的任务中失败了.

我想知道(1)如何使用new Foundation.Tooltip(2)我需要,modernizr因为基金会网站的文档没有提到modernizr作为要求.

我提到过, modernizr因为没有这个工具提示将没有任何样式,也不会显示内部的html.

谢谢

<!DOCTYPE html>
<meta name="robots" content="noindex">
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>JS Bin</title>
</head>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script> -->
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.3.1/js/foundation.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.3.1/css/foundation.css" />

<body>
    <div class="row">
        <span class="has-tip" title="Tooltips are awesome, you <a>link</a> totally use them!">
          Hover me
        </span>
    </div>



    <script id="jsbin-javascript">
        $(document).ready(function() {
            new Foundation.Tooltip($(".has-tip"), {
                allowHtml: true
            });

            // $(document).foundation();
        })
    </script>
</body>

</html>
Run Code Online (Sandbox Code Playgroud)

html javascript jquery zurb-foundation

12
推荐指数
2
解决办法
688
查看次数

Angular + jQuery,当图像的src改变时触发滚动

当我按下右/左箭头时,我试图使用jQuery滚动到特定的缩略图(在模态内)(当用户点击图像时会弹出模态).当用户点击缩略图时,我能够使滚动工作,但当变量current2改变时,我无法触发点击.任何帮助,将不胜感激.

我是Angular.js的新手,所以如果有其他建议来改进代码,我们将不胜感激.

jsbin链接

<body ng-app="mediaGallery" class="ng-cloak" ng-controller="mediaGalleryCtrl">

    <div class="row">
        <div class="small-8 columns">
            <div class="small-3 columns">
                <div ng-repeat="obj in array">
                    <div ng-if="$index < 4">
                        <img ng-click="changeMainMedia($index, 'current1')" class="thumbnail" ng-src="{{obj.src}}" />
                    </div>
                    <div ng-if="$index == 4">
                        <div class="thumbnail" data-open="media-gallery">
                            <label class="text-right success label">{{array.length - 3}} +</label>
                        </div>
                    </div>
                </div>

            </div>

            <div class="small-9 columns">
                <img data-open="media-gallery" class="main-gallery" ng-src="{{array[current1].src}}" />
            </div>
        </div>
    </div>



    <div ng-keydown="key($event)" id="media-gallery" class="small reveal text-center media-gallery" data-reveal>
        <div class="modal-body">
            <div class="main-media">
                <img class="main-gallery media-gallery-main" ng-src="{{array[current2].src}}" />
                <hr>

                <div …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery angularjs

11
推荐指数
1
解决办法
728
查看次数

F#.NET Core 2.1简单的crud app:控制器没有注册

我试图使用F#与.NET Core 2.1创建一个简单的CRUD应用程序,但没有一个控制器没有注册.我看不到Swagger中的控制器和控制器本身都没有启动.

我感谢任何帮助或提示.

Startup.fs

namespace SimpleCms

type Startup private () =
    let mutable configuration : IConfigurationRoot = null

    member this.Configuration
        with get () = configuration
        and private set (value) = configuration <- value

    new(env : IHostingEnvironment) as this =
        Startup()
        then 
            let builder =
                ConfigurationBuilder()
                    .SetBasePath(env.ContentRootPath)
                    .AddJsonFile("appsettings.json", optional = false, reloadOnChange = true)
                    .AddJsonFile(sprintf "appsettings.%s.json" env.EnvironmentName, optional = true)
                    .AddEnvironmentVariables()

            this.Configuration <- builder.Build()

    // This method gets called by the runtime. Use this method to add services to the …
Run Code Online (Sandbox Code Playgroud)

f# .net-core

11
推荐指数
1
解决办法
278
查看次数

角度错误:请添加@NgModule批注

我是Angular的新手,我正在尝试编写一个简单的模块化应用程序。但是我收到以下错误:

未捕获的错误:模块'SomeModule'导入了意外的指令'SomeComponent'。请添加一个@NgModule批注。

基本上,我不想导入中的所有服务和组件app.module.ts,我想对代码进行模块化,但失败了。

这是 app.module.ts

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent
  ],
  imports: [
    BrowserModule,
    RouterModule.forRoot(appRoutes),
    HttpClientModule,
    ReactiveFormsModule,
    SomeModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule {
}
Run Code Online (Sandbox Code Playgroud)

这是嵌套模块:

@NgModule({
  imports: [
    CommonModule,
    SomeComponent
  ],
  providers: [SomeService],
  declarations: [],
  exports: [SomeComponent]
})
export class SomeModule {
}
Run Code Online (Sandbox Code Playgroud)

这是嵌套的组件:

@Component({
  selector: 'app-index',
  templateUrl: './some.component.html',
  styleUrls: ['./some.component.css']
})
export class SomeComponent implements OnInit {

  somes: Array<ISome>;

  constructor(private http: HttpClient, private service: SomeService) {}

  ngOnInit() {
    this.getSomes();
  }

  getSomes() { …
Run Code Online (Sandbox Code Playgroud)

angular

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

在返回之前,StructureMap代理所有实例或修改实例

在StructureMap,我们可以代理TInterface,并TConcreteImplTProxy这个这一点:

ConfigurationExpression config = ...

config.For<TInterface>().DecorateAllWith<TProxy>();

config.For<TInterface>().Use<TConcreteImpl>();
Run Code Online (Sandbox Code Playgroud)

我想使用DispatchProxy(并在方法调用之前和调用之后全局记录),并为从StructureMap实例化的所有类型全局注册它,我想知道如何实现这一点?

更具体地说,我要对要实例化的所有类型运行以下命令:

TConcreteImpl instance = ...

TInterface proxy = DispatchProxyGenerator.CreateProxyInstance(typeof (TInterface), typeof (TProxy))
     .SetParameters(instance);
Run Code Online (Sandbox Code Playgroud)

我已经尝试过IInstancePolicyStructureMap,但是没有成功,因为Instance它不是实际的对象实例。

public class Policy : IInstancePolicy
{
    public void Apply(Type pluginType, Instance instance)
    {

    }
}
Run Code Online (Sandbox Code Playgroud)

非常感谢

c# structuremap .net-core

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

正如在维基百科上所说的那样实现LLL算法,但是遇到了严重的问题

我不确定我的问题是关于编程还是与LLL算法的概念有关,以及维基百科上提到的内容.

我决定实施LLL算法,因为它已经在维基百科上编写(逐步/逐行),以实际学习算法并确保它真正有效,但我得到意外或无效的结果.

所以,我使用JavaScript(编程语言)和node.js(JavaScript引擎)来实现它,这是获取完整代码的git存储库.

长话短说,K的值超出范围,例如当我们只有3个向量(数组大小为3,因此索引的最大值为2)时,k变为3并且它是无意义的.

我的代码是维基百科上提到的算法的逐步(逐行)实现,我所做的只是实现它.所以我不是什么问题.

// ** important
//  {b} set of vectors are denoted by this.matrix_before
//  {b*} set of vectors are denoted by this.matrix_after
calculate_LLL() {
    this.matrix_after = new gs(this.matrix_before, false).matrix; // initialize after vectors: perform Gram-Schmidt, but do not normalize
    var flag = false; // invariant
    var k = 1;

    while (k <= this.dimensions && !flag) {
        for (var j = k - 1; j >= 0; …
Run Code Online (Sandbox Code Playgroud)

javascript algorithm cryptography node.js ecmascript-6

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

AWS Kinesis .NET使用者

我正在使用AWS Kinesis与生产者和消费者进行试验,但问题是,尽管我们多次更改了发送的数据对象,但消费者仍继续收到我们产生的第一条消息(或记录)。此外,我们尝试了多个ShardIteratorType,但没有一个起作用。最新不会产生任何结果,所有其他都会产生相同的原始记录。

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Amazon;
using Amazon.Internal;
using Amazon.Kinesis;
using Amazon.Kinesis.Model;
using BenchmarkRuleSetModel.Models;
using MongoDB.Driver;
using Newtonsoft.Json;

namespace ConsoleApp7
{
    internal class Program
    {
        private static AmazonKinesisClient _client;
        private static string _streamName;

        static async Task ReadFromStream()
        {
            var kinesisStreamName = _streamName;

            var describeRequest = new DescribeStreamRequest
            {
                StreamName = kinesisStreamName,
            };

            var describeResponse = await _client.DescribeStreamAsync(describeRequest);
            var shards = describeResponse.StreamDescription.Shards;

            foreach (var shard in shards)
            {
                var iteratorRequest = new GetShardIteratorRequest …
Run Code Online (Sandbox Code Playgroud)

c# amazon-web-services amazon-kinesis .net-core

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

Multiple user type Identity - DbContext design

I'm trying to use the Identity package of .NET Core with multiple classes that extend IdentityUser<Guid> but with a single UserRole class.

I have multiple classes that extend UserStore<T> for each user type and a single class that extends RoleStore<UserRole>.

The following is my startup.cs:

services.AddIdentity<InternalUser, UserRole>(IdentityOptions)
    .AddDefaultTokenProviders()
    .AddUserStore<InternalUserStore>()
    .AddRoleStore<GenericUserRoleStore>();

services.AddIdentityCore<Contractor>(IdentityOptions)
    .AddRoles<UserRole>()
    .AddDefaultTokenProviders()
    .AddUserStore<ContractorUserStore>()
    .AddRoleStore<GenericUserRoleStore>();

services.AddIdentityCore<Homeowner>(IdentityOptions)
    .AddRoles<UserRole>()
    .AddDefaultTokenProviders()
    .AddUserStore<HomeownerUserStore>()
    .AddRoleStore<GenericUserRoleStore>();
Run Code Online (Sandbox Code Playgroud)

My DbContext is not extending IdentityDbContext:

public sealed class EntityDbContext: DbContext { }
Run Code Online (Sandbox Code Playgroud)

I was getting multiple …

c# entity-framework asp.net-identity .net-core asp.net-core

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

Nancy不渲染视图也不扩展布局视图

我开始在Mono(Ubuntu)和Nancy学习C#,它是C#的Web框架.我正在使用他们的"超级简单视图引擎"渲染,我无法使代码呈现.sshtml文件,它只是显示为计划文本文件.最终,我想使用布局文件(layout.sshtml),每个视图将替换部分布局文件.

我有一种预感,也许文件夹结构无效,例如login.sshtml找不到layout.sshtml.但我修改了.csproj文件以复制Views文件夹:

  <Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Debug' ">
    <!-- needed to deply views folder -->
    <Exec Command="cp -a  Views $(OutDir)" />
    <!-- needed to deply database if not newer -->
    <Exec Command="cp -a -u  Database/db.sqlite $(OutDir)" />
  </Target>
Run Code Online (Sandbox Code Playgroud)

我只是为什么它不呈现视图感到困惑.任何帮助,将不胜感激.

这是我的存储库的链接

这是我项目的文件夹结构:

??? bin
?   ??? Debug
?       ??? csharp-practice.exe
?       ??? csharp-practice.exe.mdb
?       ??? db.sqlite
?       ??? Nancy.dll
?       ??? Nancy.Hosting.Self.dll
?       ??? nancy-simple-app.exe
?       ??? nancy-simple-app.exe.mdb …
Run Code Online (Sandbox Code Playgroud)

c# mono nancy

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

Autofac 与 .NET 6 控制台应用程序和 ServiceCollection

我正在尝试使用Autofac在控制台应用程序中ServiceCollection填充。ServiceCollection我通读了文档,但没有针对我的具体场景的指南。

我面临的问题是,当我询问接口类型时,构建的 ServiceCollection 找不到实现。我认为 AutoFac 没有填充ServieCollection.

Program.cs

using System.Reflection;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using Core.Interfaces;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;


var serviceProvider = new ServiceCollection()
    .AddLogging(cfg => cfg.AddConsole())
    .Configure<LoggerFilterOptions>(cfg => cfg.MinLevel = LogLevel.Information)
    .AddAutofac(cfg =>
    {
        cfg.RegisterAssemblyTypes(Assembly.Load("Core")).AsImplementedInterfaces();
    })
    .BuildServiceProvider();

var markDownParser = serviceProvider.GetRequiredService<IMarkDownParser>();
Run Code Online (Sandbox Code Playgroud)

MarkDownParser.cs

namespace Core;

public class MarkDownParser : IMarkDownParser
{
    private readonly ILogger<MarkDownParser> _logger;

    public MarkDownParser(ILogger<MarkDownParser> logger)
    {
        _logger = logger;
    }
}
Run Code Online (Sandbox Code Playgroud)

IMarkDownParser.cs

namespace Core.Interfaces;

public interface IMarkDownParser
{
    object …
Run Code Online (Sandbox Code Playgroud)

c# autofac asp.net-core .net-6.0

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