有没有办法在TypeScript中获取类的属性名称:在示例中,我想"描述"类A或任何类并获取其属性的数组(可能只是公共的?),是否可能?或者我应该首先实例化对象?
class A {
private a1;
private a2;
/** Getters and Setters */
}
class Describer<E> {
toBeDescribed:E ;
describe(): Array<string> {
/**
* Do something with 'toBeDescribed'
*/
return ['a1', 'a2']; //<- Example
}
}
let describer = new Describer<A>();
let x= describer.describe();
/** x should be ['a1', 'a2'] */
Run Code Online (Sandbox Code Playgroud) 我正在尝试在Doctrine中使用继承类型,但是当我创建数据库时,它显示以下错误消息:
[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation "@InheritanceType" in class iMed\GestInfo
rmatiqueBundle\Entity\MaterielInformatique was never imported. Did you mayb
e forget to add a "use" statement for this annotation?
Run Code Online (Sandbox Code Playgroud)
父类是.
namespace iMed\GestInformatiqueBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* MaterielInformatique
*
* @ORM\Table(name="MATERIEL_INFORMATIQUE")
* @ORM\Entity
* @InheritanceType("JOINED")
* @DiscriminatorColumn(name="nature", type="string")
* @DiscriminatorMap({"PCMP" = "PC", "IMPR" = "Imprimante", "ECRN" = "Ecran"})
*/
class MaterielInformatique
{
/**
* @var integer
*
* @ORM\Column(name="ID", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
////
}
Run Code Online (Sandbox Code Playgroud)
似乎我需要添加一行来导入一个类,但我不知道什么是类,有人有想法解决这个问题吗?
我有一个简单的应用程序,当我尝试导航到路线时,我有一个问题.我的主要内容:
@Component({
selector: 'my-app',
template: `
<ul class="my-app">
<li>
<a [routerLink]="['Login']">Login</a>
</li>
<li>
<a [routerLink]="['Projects']">Projects</a>
</li>
</ul>
<br>
<router-outlet></router-outlet>`,
directives: [ROUTER_DIRECTIVES],
providers: [ROUTER_PROVIDERS]
})
@RouteConfig([
{
path: '/Login',
name: 'Login',
component: LoginFormComponent,
useAsDefault: false
},
{
path: '/Projects',
name: 'Projects',
component: ListProjectsComponent,
useAsDefault: true
}
])
export class AppComponent { ...
...
Run Code Online (Sandbox Code Playgroud)
我有一个基本的组件
@Component({
selector: 'login-form',
template:
`
<button (click)="goToProjects()">Go To Projects!</button>
`,
directives: [ROUTER_DIRECTIVES],
providers: [LoginService, ROUTER_PROVIDERS]
})
export class LoginFormComponent implements OnInit {
...
goToProjects(){
let link = …Run Code Online (Sandbox Code Playgroud) 我试图理解为什么我的程序不会编译,
int myfunction(int x)
{
return x;
}
int main(){
int x = 10;
int result=0;
result=myfunction(x) * myfunction(++x);
printf("Result is = %d", result);
}
Run Code Online (Sandbox Code Playgroud)
执行后我得到:警告被视为错误在函数'int main()'中:'x'上的操作可能是未定义的.有人有想法吗?
php doc中标签的确切顺序是什么?有没有遵循的约定?还是“随机”?例如:
* Some instructions
* @example $entity->id; $entity->content ...
* @throws MyException
* @return mixed
* @see ThisClass
Run Code Online (Sandbox Code Playgroud)
* Some instructions
* @throws MyException
* @example $entity->id; $entity->content ...
* @see ThisClass
* @return mixed
Run Code Online (Sandbox Code Playgroud)
到目前为止“等效”吗?
为什么void i( )没有像'Normal'函数那样调用下面的函数.
void i(){
cout << 10 << endl;
}
int main(){
class i {
int j;
};
i();//
return 0;
}
Run Code Online (Sandbox Code Playgroud)
预期的正常行为是打印1O,但我没有得到任何东西,不是编译器警告也不是结果.
angular ×1
c ×1
c++ ×1
doctrine-orm ×1
php ×1
phpdoc ×1
reflection ×1
symfony ×1
typescript ×1