我尝试使用列属性映射我的Id字段,但由于某种原因,这似乎不起作用,我无法弄清楚原因.我建立了一个测试项目来展示我正在尝试的东西.
首先,我得到了我的2个实体:
实体表1
using System.Data.Linq.Mapping;
namespace DapperTestProj
{
public class Table1
{
[Column(Name = "Table1Id")]
public int Id { get; set; }
public string Column1 { get; set; }
public string Column2 { get; set; }
public Table2 Table2 { get; set; }
public Table1()
{
Table2 = new Table2();
}
}
}
Run Code Online (Sandbox Code Playgroud)
和实体表2
using System.Data.Linq.Mapping;
namespace DapperTestProj
{
public class Table2
{
[Column(Name = "Table2Id")]
public int Id { get; set; }
public string Column3 { get; set; } …Run Code Online (Sandbox Code Playgroud) 我在桌面模式下使用谷歌图表,在表格中我希望内容(文本)与边界有一点距离.我尝试用css做到这一点,但填充,边距和他们的-left变种到目前为止还不起作用.链接到tableCell属性的css(它是google图表的cssClassNames属性的一部分)正在工作,因为我可以设置边框和背景.但是当我尝试设置填充或边距等时没有任何变化.那么我需要做些什么才能在边框和表格中的内容之间创建距离?
这是我使用的Google图表:https://developers.google.com/chart/interactive/docs/gallery/table
我尝试在2x2位置形成一个4格的网格.在这些div之间我想要一个宽度为1像素的边框,基本上看起来像这样:
1|2
-+-
3|4
Run Code Online (Sandbox Code Playgroud)
div必须在大小上相等,并且总体上需要以任何分辨率全屏显示.我的第一个想法是为行创建2个div,并在每个div中为列添加2个div,向左浮动.到目前为止,我有完美的行,但只要我添加div之间的边框就会出现一个滚动条.显然,边框不包括在宽度中:50%.我怎样设法得到这个?
到目前为止这是我的代码.
CSS
html, body
{
margin: 0;
padding: 0;
width: 100%;
min-height: 100%;
}
.row
{
Width: 100%;
Height: 50%;
}
.border
{
border-bottom: 1px solid black;
}
Run Code Online (Sandbox Code Playgroud)
HTML
<div class="row border" style="background-color: red;">
</div>
<div class="row" style="background-color: blue">
</div>
Run Code Online (Sandbox Code Playgroud)
我还尝试使代码在小提琴演示中运行:DEMO但由于某种原因,身高和/或html的高度100%将无效.
我目前正在youtube 上关注本教程,大约 26 分钟时,作者正在使用该firebase serve命令在本地运行他的功能。
这对他来说很好,但是一旦我尝试这样做,我就会收到下一个错误:
Run Code Online (Sandbox Code Playgroud)Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information. at GoogleAuth.getApplicationDefaultAsync (D:\\...\functions\node_modules\google-auth-library\build\src\auth\googleauth.js:161:19) at process._tickCallback (internal/process/next_tick.js:68:7)
现在,错误给了我一个链接,通过在我的 Windows 中设置一个环境变量来帮助我解决这个错误(我不喜欢,因为当我在链接到的不同项目中开发时,这将如何工作?不同的 Gmail 帐户?)
我发现但尚未测试的另一个解决方案是使用 gcloud 命令在本地进行身份验证gcloud auth application-default login。
这些步骤都不是作者在教程中完成的。
我在视频的评论中搜索,有人提到它与 firebase-tools 版本有关。他的解决方案是回到 firebase-tools 版本 6.8.0,而当前最新版本是 7.2.2。
所以我想知道,当使用 firebase-tools 6.8 时,当云函数尝试在远程 firestore 数据库中存储一些东西时,firebase 与 firebase-tools 7.2.2 一起服务的变化无法再运行云函数。 0?
它是否会像使用 6.8.0 版本那样使用 7.2.2 或更高版本?
有没有可能用更短、可读的代码编写下一个开关?
switch (SomeValue)
{
case "001": return DoMethod1(); break;
case "002": return DoMethod2(); break;
//etc..
}
Run Code Online (Sandbox Code Playgroud)
我在想以某种方式
Dictionary<string, Func<int>> MethodsByValue = new Dictionary<string, Func<int>>()
{
{ "001", DoMethod1 },
{ "002", DoMethod2 },
}
Run Code Online (Sandbox Code Playgroud)
并通过这样做来调用它
return MethodsByValue[SomeValue]();
Run Code Online (Sandbox Code Playgroud)
但这可能吗?或者说我的想法太离谱了。我找不到这样的东西,但话又说回来,如果可能的话,我不知道这个的关键字。
编辑:回答 Lasse V. Karlsen 的请求:
这就是我的项目中的代码的样子。在某些地方更改了名称,因为原来的名称并不重要,因为它是我的母语。
public string GetRecord420(Dictionary<DataClass, object> dictionaryName)
{
// some code here
}
public string GetRecord421(Dictionary<DataClass, object> dictionaryName)
{
// some code here
}
//(Temperary) solution with the switch statement in a wrapper:
public string GetRecordByString(string s, Dictionary<DataClass, …Run Code Online (Sandbox Code Playgroud) 最近,我开始学习结合使用firebase和angular的概念。首先,我尝试使登录过程正常进行。当前,当我尝试导航到登录页面时收到一个令人讨厌的错误,并且我无法弄清楚是什么原因导致了该错误。我得到的错误是:
错误错误:未捕获(承诺):错误:StaticInjectorError(AppModule)[AngularFireAuth-> InjectionToken angularfire2.app.options]:StaticInjectorError(平台:核心)[AngularFireAuth-> InjectionToken angularfire2.app.options]:NullInjectorError:没有提供程序InjectionToken angularfire2.app.options!
我该怎么办才能解决此错误?另外,我看到很多使用angularfire2而不是@ angular / fire的代码。这2个和我实际应该使用哪个有什么区别?
这是我到目前为止的代码:
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AngularFireModule } from '@angular/fire';
import { AngularFireDatabaseModule } from '@angular/fire/database';
import { environment } from 'environments/environment';
import * as firebase from 'firebase/app';
import { AppComponent } from './app.component';
import { FIREBASE_SERVICES } from './core/firebase/services';
import { AUTHENTICATION_GUARDS } from './features/authentication/guards';
import { AUTHENTICATON_ROUTES } from './features/authentication/authentication.route';
import …Run Code Online (Sandbox Code Playgroud) firebase firebase-authentication typescript2.0 angular angular7
在与Web服务建立连接的过程中,我尝试使用AngularJS $ http选项对其进行管理。但是,当我尝试对其进行测试时,我在chrome控制台中遇到了下一个错误:ReferenceError分配的左侧无效。我检查了3次代码,但无法弄清楚自己在做什么错。这是我的睾丸:
<!doctype html>
<html ng-app>
<head>
<title>Test webservice</title>
<script type="text/javascript" src="./jquery-1.9.1.js"></script>
<script type="text/javascript" src="./angular.min.js"></script>
<script type="text/javascript" src="./angular-resource-min.js"></script>
<script type="text/javascript">
function testWebservice($scope, $http) {
$scope.testService() = function() {
$http.get("http://localhost:1325/hello/world")
.success(function(data, status, headers, config) {
alert(data);
})
.error(function(data, status, headers, config) {
alert(status);
});
};
}
</script>
<head>
<body>
<div ng-controller="testWebservice">
<form ng-submit="testService()">
<input type="submit" value="test">
</form>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我在www.angularjs.org上使用了“添加某些控件”示例作为测试脚本。我的Web服务等于ServiceStack的教程:http : //www.servicestack.net/ServiceStack.Hello/
我的问题是,什么原因导致我在angular.min.js文件中收到错误?
我正在努力学习如何使用角度指令,到目前为止成功.我只有一个小问题,我无法弄清楚.
在我的指令中,我在输入字段的id的相同值上设置了for属性.但是单击标签并不会使输入控件成为正常工作的焦点.
我在一些示例代码中解决了这个问题:
<div ng-app='test' ng-controller='testCtrl'>
<label for="test1">Testlabel 1</label><br>
<input id="test1" type="text"></input><br>
<my-input id="test2"
label="Testlabel 2"
placeholder="enter somthing"
text="testVar"></my-input><br>
<span>{{testVar}}</span>
</div>
Run Code Online (Sandbox Code Playgroud)
和javascript:
angular.module('test', [])
.directive('myInput', function() {
return {
restrict: 'E',
template: '<label for={{id}}>{{label}}</label><br>' +
'<input id={{id}} type="text" ' +
' placeholder={{placeholder}} ng-model="text" />',
scope: {
id: "@",
label: "@",
placeholder: "@",
text: "="
}
}
})
.controller('testCtrl', ['$scope', function($scope) {
$scope.testVar = 'testing';
}]);
Run Code Online (Sandbox Code Playgroud)
jsfiddle中的相同代码:http://jsfiddle.net/U92em/
我犯了什么错误导致我的问题,我该如何解决?
我有一个<button>元素,在其中,一个<p>元素.该<p>元素与css结合使用margin-top,在类中垂直对齐按钮内的文本(按钮具有特定高度).
html看起来像这样:
<button class="someClass">
<img ... />
<p class="anotherClass">Caption</p>
</button>
Run Code Online (Sandbox Code Playgroud)
这样工作正常,文本垂直对齐,就像应该的那样.但是我在visual studio 2012里面发出警告说:
元素'p'不能嵌套在元素'button'中.
我的问题:为什么<p>元素内部不允许<button>元素?还有什么选择?
为了学习 C#、XAML,尤其是 MVVM,我开始编写扫雷游戏。我制作的第一个版本没有 MVVM 部分,我使用 C# 代码创建和添加按钮,而不是通过 MVVM 方式在 XAML 中进行。现在我尝试将 MVVM 模式应用到游戏中。
我制作了一个自己的用户控件,其中包含一个代表雷区部分的按钮。这个控件还有一个 ViewModel 和一个 Model Class 来存储一些状态数据和处理一些命令。在一个测试项目中,我创建了 4 个自己的用户控件,并尝试将它们放在一个网格中,其中按钮形成一个 2 x 2 按钮的正方形。在后面的代码中,按钮被放在一个 ObservableCollection 对象中。我假设在这个对象中,按钮被列出和索引如下:
Button1
Button2
Button3
Button4
Run Code Online (Sandbox Code Playgroud)
但在演示文稿网格中,我希望按钮显示为
Button1 | Button2
--------+--------
Button3 | Button4
Run Code Online (Sandbox Code Playgroud)
问题是:我如何动态地做到这一点?因为在我的测试项目中我测试了 4 个按钮,但是在我想使用它的项目中,按钮的数量可能会根据玩家选择的游戏难度而有所不同。
第二个问题是我如何弄清楚按钮的 neigbhours 是什么。因此,如果网格是包含 20 个按钮的 4 x 5。例如,我选择按钮 8,它的邻居按钮编号为 2、3、4、7、9、12、13 和 14。当按钮被列出时,我怎样才能到达这些邻居按钮?
我希望我的问题足够清楚。
先感谢您!
我有一个选择属性倍数.对于select中的每个选项,我想要title属性集(显示工具提示).我还想将所选选项检索为对象数组.我设法得到了我想要的东西,除了选择的选项不返回一个对象数组但是返回一个valueTexts数组的事实.我无法弄清楚如何在该数组中获取对象.
这是我到目前为止的代码:
HTML:
<select multiple style="width: 150px;" size=15
data-bind="foreach: options, selectedOptions: selectedOptions">
<option data-bind="text: Name, attr: { 'title': Name}"></option>
</select><br />
<button data-bind="click: showSelectedOptions">Show selection</button>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
function Option(id, name){
var self = this;
self.Id = id;
self.Name = name;
}
function ViewModel(){
var self = this;
self.options = ko.observableArray([
new Option(0, "NormalText"),
new Option(1, "AnotherText"),
new Option(2, "WaaaaaaaaaaaaaaaayTooLongText")
]);
self.selectedOptions = ko.observableArray([]);
self.showSelectedOptions = function(){
alert(self.selectedOptions());
//what I would like to have:
//if (self.selectedOptions().length > 0)
// alert(self.selectedOptions()[0].Name);
}
} …Run Code Online (Sandbox Code Playgroud) javascript ×4
c# ×3
html ×3
angularjs ×2
firebase ×2
angular ×1
angular7 ×1
css ×1
css3 ×1
dapper ×1
firebase-cli ×1
html5 ×1
knockout.js ×1
mvvm ×1
xaml ×1