我一直在玩Facebook的draft-js,但我实际上无法弄清楚如何获得编辑器的html输出.以下示例中的console.log输出一些_map属性,但它们似乎不包含我的实际内容?
class ContentContainer extends React.Component {
constructor(props) {
super(props);
this.state = {
value: '',
editorState: EditorState.createEmpty()
};
this.onChange = (editorState) => this.setState({editorState});
this.createContent = this.createContent.bind(this);
}
createContent() {
console.log(this.state.editorState.getCurrentContent());
}
render() {
const {editorState} = this.state;
const { content } = this.props;
return (
<Template>
<br /><br /><br />
<ContentList content={content} />
<div className="content__editor">
<Editor editorState={editorState} onChange={this.onChange} ref="content"/>
</div>
<FormButton text="Create" onClick={this.createContent.bind(this)} />
</Template>
);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试开发一个类库,我想在其中实现自定义DbContext.在SaveChanges方法中DbContext,我需要获取当前用户的信息(部门,用户名等)以供审计.DbContext代码的某些部分如下:
public override int SaveChanges()
{
// find all changed entities which is ICreateAuditedEntity
var addedAuditedEntities = ChangeTracker.Entries<ICreateAuditedEntity>()
.Where(p => p.State == EntityState.Added)
.Select(p => p.Entity);
var now = DateTime.Now;
foreach (var added in addedAuditedEntities)
{
added.CreatedAt = now;
added.CreatedBy = ?;
added.CreatedByDepartment = ?
}
return base.SaveChanges();
}
Run Code Online (Sandbox Code Playgroud)
想到两个选项:
HttpContext.Items保存用户信息,注入IHttpContextAccessor并从中获取信息
HttpContext.Items(在这种情况下DbContext取决于HttpContext,是否正确?)HttpContext.Items从对象获取信息(我读了一些ThreadStatic不安全的帖子)问题:哪种情况最适合我的情况?你有其他建议吗?
在我们的项目中,我们经常忘记更新Package.json文件中的版本号.我们是一个AngularJS项目.在我们的包JSON文件中,我们指定了以下两个版本信息
"version": "1.0.7",
"devVersion": "1.0.4"
Run Code Online (Sandbox Code Playgroud)
在合并分支开发之前,我想要一个自动脚本来更新以上两个版本号.我在想Git Hooks会帮助我.
我在哪里可以找到钩子,我能够在.git文件夹下的本地仓库中看到钩子.我很困惑使用哪个钩子.在Google上搜索建议我必须在服务器上创建钩子.
我在哪里可以找到它们,我可以更新上面的两个键(版本和devVersion)?
请提示使用位置和挂钩,这样可以解决很多问题.
我正在尝试制作一个带有平台的空白Android应用程序。为此,我已经安装并尝试为. 但是,当我尝试运行它时,即使构建成功,它也会在部署时出现错误,并且不会显示任何错误消息。我正在使用 512 RAM 的模拟器(AVD)。XamarinVisual Studio 2015VS2015XamarinAndroid
我尝试清理解决方案、重建并以管理员身份运行,但无法跟踪任何错误。我也在 SO 上搜索过提示,但找不到任何提示。
我想WebApi通过Ajax请求从控制器向Html页面发送一个对象.
当我在JS中收到对象时,它是空的.但是服务器端的对象不是空的,因为当我看到byte[].length它大于0时.
JS方面,我使用的是ProtobufJS库.这是我的.proto档案:
syntax="proto3";
message Container {
repeated TestModel2 Models = 1;
}
message TestModel2 {
string Property1 = 1;
bool Property2 = 2;
double Property3 = 3;
}
Run Code Online (Sandbox Code Playgroud)
服务器代码:
var container = new Container();
var model = new TestModel2
{
Property1 = "Test",
Property2 = true,
Property3 = 3.14
};
Run Code Online (Sandbox Code Playgroud)
container.Models.Add(模型);
Base64数据:
ChEKBFRlc3QQARkfhetRuB4JQA ==
JS解码:
var ProtoBuf = dcodeIO.ProtoBuf;
var xhr = ProtoBuf.Util.XHR();
xhr.open( …Run Code Online (Sandbox Code Playgroud)我需要将hosts文件中定义的主机名解析为其对应的IP地址.
例如我的主机文件看起来像这样 - "/ etc/hosts"
127.0.0.1 ggns2dss81 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.253.8 abcdserver
192.168.253.20 testwsserver
Run Code Online (Sandbox Code Playgroud)
现在在我node.js,我可以阅读这个文件的内容,但我需要获取给定的hostname.
hostname = "testwsserver"
hostIP = getIP(hostname);
console.log(hostIP); // This should print 192.168.253.20
Run Code Online (Sandbox Code Playgroud)
PS - npm pkg或任何第三方软件包无法安装在计算机上.
非常感谢帮助!!
这是我的javascript代码
$scope.addUser = function () {
debugger;
url = baseURL + "AddUser";
$scope.objUser = [];
$scope.objUser.push( {
"ID": '0',
"UserName": $scope.txtUserName,
"Password": $scope.txtPassword,
"Role":"Non-Admin"
});
$http.post(url,$scope.objUser[0])
.success(function (data) {
debugger;
alert("S");
window.location = "../View/Login.html";
}).error(function () {
debugger;
alert("e");
});
}
Run Code Online (Sandbox Code Playgroud)
这是我的服务器方法代码
[HttpPost]
public int AddUser(UserModel user)
{
//_entity.Configuration.ProxyCreationEnabled = false;
tblUser objUser = new tblUser();
objUser.UserName = user.UserName;
objUser.Password = user.Password;
objUser.Role = user.Role;
_entity.tblUsers.Add(objUser);
_entity.SaveChanges();
return objUser.ID;
}
Run Code Online (Sandbox Code Playgroud) 所以我刚刚注册了Mailgun,我没有输入任何信用卡信息,也没有验证域名或任何类似的东西。Mailgun但是,我确实验证了我的帐户。
我的问题是由于某种原因,我只能向我注册该Mailgun帐户的电子邮件地址发送电子邮件。例如,我用来设置帐户的电子邮件Mailgun是peppa@gmail.com,我只能向 发送电子邮件peppa@gmail.com,如果我输入另一个电子邮件地址,则什么也不会发生。
任何帮助表示赞赏。我的目标是能够向任何地址发送电子邮件。
我使用Images.jl在Julia.我试图将图像转换为类似图形的数据结构(v,w,c)
v是一个节点
w是邻居和
c是成本函数
我想给那些颜色不同的邻居付出昂贵的代价.但是,当我加载图像时,每个像素都有以下类型RGBA{U8}(1.0,1.0,1.0,1.0),有没有办法将其转换为Int64或Float等数字?
我正在构建一个Android应用程序Visual Studio 2015.它运作良好.我收到部署错误.当我清洁和重建项目成功没有错误.但是,当我尝试从Visual Studio运行应用程序时,它告诉我发生了部署错误.
构建输出错误:
无法解决"System.Xml,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089"和"System.Xml,Version = 2.0.5.0,Culture = neutral,PublicKeyToken = 7cec85d7bea7798e"之间的冲突.任意选择"System.Xml,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089".
我也尝试过真正的设备.它还显示设备和模拟器上的部署错误.