例如,我想在angular中添加一个registerController方法,我将得到
Property 'registerController ' does not exist on type 'IAngularStatic'
我通过创建一个* .d.ts来解决这个问题
import * as angular from 'angular';
declare module 'angular' {
interface IAngularStatic {
registerController : any;
}
}
但是为什么我应该使用import * as angular from 'angular'
而///<reference types="angular">
不起作用
答案 0 :(得分:0)
只需编写您自己的接口并像这样扩展MessageLabel = new Label
{
FontAttributes = FontAttributes.None,
FontSize = 18,
HorizontalTextAlignment = TextAlignment.Start,
VerticalTextAlignment = TextAlignment.Center,
HorizontalOptions = LayoutOptions.StartAndExpand,
TextColor = Color.Black
};
ScrollView scroll = new ScrollView()
{
Orientation = ScrollOrientation.Vertical
};
scroll.Content = MessageLabel;
:
IAngularStatic
,而改用import {IAngularStatic} from "angular";
export interface ExtendedAngularStatic extends IAngularStatic {
registerController: any;
}
。