小编Mik*_*unn的帖子

在ASP.NET Core中的Program.Main中访问环境名称

使用ASP.NET Mvc Core我需要将我的开发环境设置为使用https,因此我将以下内容添加到MainProgram.cs中的方法:

var host = new WebHostBuilder()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .UseKestrel(cfg => cfg.UseHttps("ssl-dev.pfx", "Password"))
                .UseUrls("https://localhost:5000")
                .UseApplicationInsights()
                .Build();
                host.Run();
Run Code Online (Sandbox Code Playgroud)

如何在此处访问托管环境,以便我可以有条件地设置协议/端口号/证书?

理想情况下,我会使用CLI来操纵我的托管环境,如下所示:

dotnet run --server.urls https://localhost:5000 --cert ssl-dev.pfx password
Run Code Online (Sandbox Code Playgroud)

但似乎没有办法从命令行使用证书.

c# kestrel asp.net-core

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

Angular 2输入指令修改表格控制值

我有一个简单的Angular 2指令,它修改了文本框的输入值.请注意,我正在使用模型驱动的表单方法.

@Directive({
  selector: '[appUpperCase]'
})
export class UpperCaseDirective{

  constructor(private el: ElementRef, private control : NgControl) {

  }

  @HostListener('input',['$event']) onEvent($event){
    console.log($event);
    let upper = this.el.nativeElement.value.toUpperCase();
    this.control.valueAccessor.writeValue(upper);

  }

}
Run Code Online (Sandbox Code Playgroud)

dom正确更新,但模型会在每次其他击键后更新.看看plnkr

angular2-forms angular2-directives angular

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

Angular $ location.path()和window.location.reload在Safari/Firefox中不起作用

出于某种原因,这适用于IE和Chrome,但不适用于Safari和Firefox.

$location.path(lastPath);
$window.location.reload(true);
Run Code Online (Sandbox Code Playgroud)

不重新加载最后一个路径,而是重新加载$window.location.reload(true)当前页面.在Chrome中IE的重新加载发生在角度发生之后$location.path(lastPath).

window.location angularjs

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

带分页的 React-Table 排序意外结果

使用react-table 时得到一些意想不到的结果。我结合了反应表示例中的分页控制和排序示例。我遇到的问题是表挂钩似乎在第二次重新渲染时将页面索引重置回默认值。这导致来回分页时 fetchData 被调用两次。以下是我面临的问题的重现:

import React from "react";
import styled from "styled-components";
import { useTable, usePagination, useSortBy } from "react-table";

import makeData from "./makeData";

const Styles = styled.div`
  `

// Let's add a fetchData method to our Table component that will be used to fetch
// new data when pagination state changes
// We can also add a loading state to let our table know it's loading new data
function Table({
  columns,
  data,
  fetchData,
  loading,
  pageCount: controlledPageCount
}) …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-table

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

使用Typescript AsyncComponent在React中的延迟加载路由

我试图通过实现AsyncCompoment类来在React中延迟加载路由,如创建React App中的代码拆分所述。以下是本教程中的es6 asyncComponent函数:

import React, { Component } from "react";

    export default function asyncComponent(importComponent) {
      class AsyncComponent extends Component {
        constructor(props) {
          super(props);

          this.state = {
            component: null
          };
        }

        async componentDidMount() {
          const { default: component } = await importComponent();

          this.setState({
            component: component
          });
        }

        render() {
          const C = this.state.component;

          return C ? <C {...this.props} /> : null;
        }
      }

      return AsyncComponent;
    }
Run Code Online (Sandbox Code Playgroud)

我已经在打字稿中编写了此函数,并且可以确认组件确实被延迟加载了。我面临的问题是它们没有被渲染。我能够确定componentDidMount挂钩中的组件对象始终是未定义的:

//AsyncComponent.tsx
async componentDidMount() {
              const { default: component } = await importComponent(); …
Run Code Online (Sandbox Code Playgroud)

lazy-loading dynamic-import typescript reactjs react-router-v4

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

Durandal SPA谷歌地图API地图中心

有一些关于谷歌地图api正确居中问题的帖子.我了解以下调整地图的大小:

google.maps.event.trigger(map, 'resize');

我能够在第一页显示的div元素内正确显示地图.但是,当导航回保存地图的html页面时,div中只显示一小部分地图.我遇到的问题是弄清楚如何合并这个调整大小的触发器.我是SPA和Durandal的新手,这是我负责地图的viewmodel:

define(['async!https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false'], function () {
    var vm = {
        title: 'Home View',
        attached: initialize,
        activate: function () {
            toastr.success('Map View Activated');
        }

    }; 
    return vm;

    function initialize() {
        var mapOptions = {
            zoom: 10,
            center: new google.maps.LatLng(-34.397, 150.644),
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
    }
});
Run Code Online (Sandbox Code Playgroud)

google-maps durandal

0
推荐指数
1
解决办法
646
查看次数