我已经在维基百科和其他网站上阅读过关于OSGi的内容,但我并没有真正看到全局.它说它是一个基于组件的平台,您可以在运行时重新加载模块.另外,给出的"实际示例"是Eclipse插件框架.
我的问题是:
OSGi的清晰简单定义是什么?
它解决了哪些常见问题?
"常见问题"我指的是我们每天面临的问题,例如"OSGi可以做些什么来提高我们的工作效率/乐趣/简单?"
在React中,这两个实现之间是否存在真正的差异?有些朋友告诉我,FirstComponent是模式,但我不明白为什么.SecondComponent似乎更简单,因为渲染只被调用一次.
第一:
import React, { PropTypes } from 'react'
class FirstComponent extends React.Component {
state = {
description: ''
}
componentDidMount() {
const { description} = this.props;
this.setState({ description });
}
render () {
const {state: { description }} = this;
return (
<input type="text" value={description} />
);
}
}
export default FirstComponent;
Run Code Online (Sandbox Code Playgroud)
第二:
import React, { PropTypes } from 'react'
class SecondComponent extends React.Component {
state = {
description: ''
}
constructor (props) => {
const { description } …
Run Code Online (Sandbox Code Playgroud) 我一直在看视频和阅读文章,但这篇特别的文章让我如此困惑,在文章的开头说
Angular中的应用程序遵循模块化结构.Angular应用程序将包含许多模块,每个模块专用于单一用途.通常,模块是一个有凝聚力的代码组,它与其他模块集成以运行Angular应用程序.
模块从其代码中导出一些类,函数和值.Component是Angular的基本块,多个组件将构成您的应用程序.
模块可以是另一个模块的库.例如,作为主要Angular库模块的angular2/core库将由另一个组件导入.
他们是可以交换的条款吗?组件是模块吗?但不是反之?
这让我疯了,我在枪下,无法再花上一整天的时间.
我试图在组件中手动设置一个控制值('dept'),它只是不工作 - 甚至新值记录到控制台正常.
这是FormBuilder实例:
initForm() {
this.form = this.fb.group({
'name': ['', Validators.required],
'dept': ['', Validators.required],
'description': ['', Validators.required],
});
}
Run Code Online (Sandbox Code Playgroud)
这是接收选定部门的事件处理程序:
deptSelected(selected: { id: string; text: string }) {
console.log(selected) // Shows proper selection!
// This is how I am trying to set the value
this.form.controls['dept'].value = selected.id;
}
Run Code Online (Sandbox Code Playgroud)
现在,当表单提交并且我注销时,this.form
该字段仍然是空白的!我已经看过其他用户,updateValue()
但这是beta.1,我不认为这是调用控件的有效方法.
我也试图打电话updateValueAndValidity()
没有成功:(.
我只是ngControl="dept"
在表单元素上使用,就像我正在使用表单的其余部分,但它是一个自定义指令/组件.
<ng-select
[data]="dept"
[multiple]="false"
[items]="depts"
(selected)="deptSelected($event)" <!-- This is how the value gets to me -->
[placeholder]="'No Dept Selected'"></ng-select>
Run Code Online (Sandbox Code Playgroud) 我的组件具有依赖于当前日期时间的样式.在我的组件中,我有以下功能.
private fontColor( dto : Dto ) : string {
// date d'exécution du dto
let dtoDate : Date = new Date( dto.LastExecution );
(...)
let color = "hsl( " + hue + ", 80%, " + (maxLigness - lightnessAmp) + "%)";
return color;
}
Run Code Online (Sandbox Code Playgroud)
lightnessAmp
是从当前日期时间计算的.如果dtoDate
是在过去24小时内,颜色会发生变化.
确切的错误如下:
检查后表情发生了变化.先前价值:'hsl(123,80%,49%)'.当前价值:'hsl(123,80%,48%)'
我知道只有在检查值时才会在开发模式中出现异常.如果选中的值与更新的值不同,则抛出异常.
所以我尝试在以下钩子方法中更新每个生命周期的当前日期时间以防止异常:
ngAfterViewChecked()
{
console.log( "! changement de la date du composant !" );
this.dateNow = new Date();
}
Run Code Online (Sandbox Code Playgroud)
......但没有成功.
这些是我的文件。我收到此错误有人可以帮助我。
Error: src/app/app.component.html:5:123 - error TS4111: Property 'fName' comes from an index signature, so it must be accessed with ['fName'].
<input id="name" type="text" formControlName="fName" class="form-control" [ngClass]="{'is-invalid':submitted && f.fName.errors}"/>
Run Code Online (Sandbox Code Playgroud)
组件.html
<form [formGroup]="surveyForm" (ngSubmit)="onSubmit()">
<div>
<label>Name:</label>
<input id="name" type="text" formControlName="fName" class="form-control" [ngClass]="{'is-invalid':submitted && f.fName.errors}"/>
<div *ngIf="submitted && f.fName.errors" class="form-control">first name is required</div>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
组件.ts
import { Component, OnInit } from '@angular/core';
import { FormControl, FormBuilder, FormGroup, Validators} from '@angular/forms';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements …
Run Code Online (Sandbox Code Playgroud) 我想知道一个类是否可以从类和接口继承.下面的示例代码不起作用,但我认为它传达了我想要做的事情.我想这样做的原因是因为我公司生产USB,串口,以太网等设备.我正在尝试开发一个通用组件/接口,我可以用它为我们所有的设备编写程序,这将有助于保持所有应用程序的常见事物(如连接,断开连接,获取固件)相同.
添加到这个问题:如果GenericDevice在不同的项目中,我可以将IOurDevices接口放在该项目中,然后如果我添加对第一个项目的引用,则使USBDevice类实现接口吗?因为想要引用一个项目,然后根据设备的不同实现不同的接口.
class GenericDevice
{
private string _connectionState;
public connectionState
{
get{return _connectionState; }
set{ _connectionState = value;}
}
}
interface IOurDevices
{
void connectToDevice();
void DisconnectDevice();
void GetFirmwareVersion();
}
class USBDevice : IOurDevices : GenericDevice
{
//here I would define the methods in the interface
//like this...
void connectToDevice()
{
connectionState = "connected";
}
}
//so that in my main program I can do this...
class myProgram
{
main()
{
USBDevice myUSB = new USBDevice();
myUSB.ConnectToDevice;
}
}
Run Code Online (Sandbox Code Playgroud) 这些是你可以添加到项目中的三个不同的东西,我不太确定我是否理解这些差异.例如,在使用a时,它们似乎都显示在组件工具箱中Form
.每种方法有哪些常见的使用方案?有什么不同?
我刚开始使用Angular 2.
我想知道Angular 2中的组件和指令之间有什么区别?
首先,我是Java EE的新手,来自强大的ASP .NET开发背景.我已经浏览了网络,我可能会错过这个,但似乎没有关于如何将支持bean类连接到JSF组件的简单直接的教程.
一个很好的例子是这样的,目前我正在尝试创建一个JSF页面,其中有一组链接作为菜单栏和一组表单.我打算做的是,当点击一个链接时,将呈现一个特定的表单.
在ASP.NET中,我可以轻松检索元素,然后将属性设置为可显示.我想知道在JSF中是否有简单的方法(哎呀,甚至任何方式).
表单已经在页面中,只需在单击特定链接时将"render"属性设置为true即可.
components ×10
angular ×5
c# ×2
class ×1
controls ×1
directive ×1
forms ×1
inheritance ×1
interface ×1
java ×1
javascript ×1
jsf ×1
module ×1
osgi ×1
reactjs ×1
styles ×1
time ×1
typescript ×1
winforms ×1