我正在尝试在visual studio中设置TypeScript HTML应用程序.我想使用reactjs v0.14.7
我想避免使用像Browserify这样的工具.
但是,如何使用该react-dom模块呢?
让我们暂时忘掉打字稿.我需要首先启动并运行纯ES5.
目前,我有这个:
<script src="Scripts/react/react.js"></script>
<script src="Scripts/react/react-dom.js"></script>
<script>
var Button = React.createClass({
render: function () {
return (React.createElement("div", { className: "btn btn-default" }, 'hello world'));
}
});
ReactDOM.render(React.createElement('Button'), document.getElementById('container'));
</script>
Run Code Online (Sandbox Code Playgroud)
但是,浏览器抱怨,ReactDOM对象不存在.
我试过了:
<script src="Scripts/require.js"></script>
<script src="Scripts/react/react.js"></script>
<script src="Scripts/react/react-dom.js"></script>
<script>
var React = require('react');
var ReactDOM = require('react-dom');
....
</script>
Run Code Online (Sandbox Code Playgroud)
但是,它不适用于require.js:模块名称"react"尚未加载上下文:_.使用require([])
有人可以为此带来更多的光吗?如何使用反应没有任何服务器端工具,如捆绑,转换等.
像"使用npm"这样的答案将不被接受为答案.
我有一堆生命周期逻辑非常相似的组件,所以我创建了我的基本组件,它实现了 OnDestroy
abstract class BaseComponent implements OnDestroy {
subscriptions = new Array<Subscription>();
get model() { return … }
ngOnDestroy() {
for (let s of subscriptions) s.unsubscribe();
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当开发人员在 extends 的具体 Component 中编写自定义 onOnDestroy 方法时ComponentBase,他无法知道他需要调用super.ngOnDestroy();
是否有一些(打字稿)方法来确保警告?或者模式其他组件继承?也许是一个单元测试,可以测试ngOnDestroy所有扩展的组件BaseComponent?
编辑
我得出结论,BaseComponent上面的订阅数组是一种常见的反模式,应该避免。理想情况下使用自动取消订阅可观察对象。
看到这个 takeUntil(destroy$) 模式:
class MyComponent implements OnInit, OnDestroy {
destroy$ = new Subject();
constructor(http: HttpService) { }
ngOnInit() {
http.get(...).pipe(
takeUntil(this.destroy$)
).subscribe(...);
}
ngOnDestroy() {
onDestroy$.onNext();
}
}
Run Code Online (Sandbox Code Playgroud) 鉴于现有的 scss 文件定义了类似.btn {..}或.btn-primary...的规则
我想通过扩展现有规则来声明我自己的规则
.my-button {
@extend .btn
@extend .btn-primary
}
Run Code Online (Sandbox Code Playgroud)
没有在我生成的 css 文件中实际包含.btn和类?.btn-primary
通常我需要@import exiting.scss,但这包括我的 css 输出中文件中的所有规则。
我有一个 css 网格(display:grid)和具有固定高度的行。
我可以将行对齐到网格顶部而不是垂直分布吗?
.grid {
height: 180px;
display: grid;
grid-template-columns: 1fr;
border: solid 1px red;
align-content: top;
align-items: top;
}
.row {
grid-column: 1 / -1;
height: 20px;
background: silver;
border: dashed 1px blue;
}Run Code Online (Sandbox Code Playgroud)
<div class="grid">
<div class="row">row 1</div>
<div class="row">row 2</div>
<div class="row">row 3</div>
</div>Run Code Online (Sandbox Code Playgroud)
dotnet watch --project app\App.csproj run,它监听不同的端口 - 5001!这是我的 launchSettings.json
"App": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"applicationUrl": "https://localhost:5003;http://localhost:5002",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"LocalUrl": "https://localhost:5003"
}
}
Run Code Online (Sandbox Code Playgroud)
为什么 dotnet run 在不同的端口上启动以及如何使其在 5003 上运行?
附加信息:
该应用程序是在.NET 5中创建的,升级SDK和PackageReferences .NET 6后出现问题,
在Visual Studio 2015 Update1中,通用Windows应用程序的XAML设计器消失了吗?
它适用于wpf和window 8.1应用程序,并且在工具 - >选项 - > XAML设计器中启用了XAML设计器
如何在visual studio外使用powershell或命令行检查指定包源(nuget服务器)中是否存在具有特定版本的nuget包?
我有私人NuGet服务器,我想推送自己的包.我在TFS构建期间自动创建了包.我想念的是检查包是否先前上传并发布到NuGet服务器.
我目前从身体读取输入流,如下所示:
public async Task<IActionResult> Post()
{
byte[] array = new byte[Request.ContentLength.Value];
using (MemoryStream memoryStream = new MemoryStream(array))
{
await Request.Body.CopyToAsync(memoryStream);
}
return Ok();
}
Run Code Online (Sandbox Code Playgroud)
由于测试和swagger生成,我想在方法签名中指定输入参数.
是否可以以某种方式将输入参数指定为流?
public async Task<IActionResult> Post([FromBody]Stream body) ...
Run Code Online (Sandbox Code Playgroud) 我已经开始使用asp.net core 2 web应用程序,我可以使用Web部署从Visual Studio将其发布到App Service.
我已经创建了新的干净.net核心2控制台应用程序.我可以将其作为webjob上传并使用Azure Portal运行,但如何从本地命令行或Visual Studio发布它?
基本上,我不关心它是与Web应用程序一起发布还是作为独立发布.
编辑:我通过右键单击项目并选择发布(不发布为Azure WebJob)作为文档中的menioned,以某种方式设法获得发布对话框.但我仍然不知道诀窍是什么.安装Azure SDK?添加webjob-publish-settings.json?添加Setting.job?
azure azure-webjobs .net-core asp.net-core visual-studio-2017
我像这样使用asp.net核心日志:
public class MyClass
{
private readonly ILogger<MyClass> _logger;
public readonly EventId NoEntryFoundEventId = new EventId(1, "No Entry Found");
public MyClass(ILogger<MyClass> logger)
{
_logger = logger;
}
public void Foo(decimal entryId)
{
_logger.LogError(NoEntryFoundEventId, "MyCustomMessage\t: Entry ID: {EntryId}", entryId);
}
}
Run Code Online (Sandbox Code Playgroud)
我设置了这样的记录器:
services.AddApplicationInsightsTelemetry();
loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Information)
Run Code Online (Sandbox Code Playgroud)
如何在Azure门户中找到MyClass的日志?
azure azure-web-sites azure-application-insights asp.net-core
asp.net-core ×4
azure ×2
css ×2
typescript ×2
.net ×1
.net-6.0 ×1
.net-core ×1
angular ×1
asp.net ×1
bootstrap-4 ×1
c# ×1
command-line ×1
commonjs ×1
css-grid ×1
dotnet-cli ×1
html ×1
inheritance ×1
javascript ×1
nuget ×1
powershell ×1
reactjs ×1
sass ×1
uwp ×1
xaml ×1