npm i --save nativescript-popup
- 版本: 1.5.0
- GitHub:
- NPM: https://npmjs.net.cn/package/nativescript-popup
- 下载次数
- 昨日: 0
- 上周: 0
- 上月: 18
安装
tns plugin add nativescript-popup
屏幕截图
用法
<Button tap="openPopup"/>
import { Popup } from 'nativescript-popup';
function openPopup(args){
const popup = new Popup({
backgroundColor:'white' | '#fff',
height:100,
width:100,
unit:'dp' | 'px' | '%',
elevation:10, // android only
borderRadius:25 // android only
});
const view = new Label();
view.text = "Test";
/* IOS */
const nativeView = UILabel.new();
nativeView.text = "Native Button";
nativeView.frame = CGRectMake(0,0,50,50);
/* -- IOS */
/* Android */
const nativeView = new new android.widget.TextView(context);
nativeView.setText("Native Button");
nativeView.setWidth(50);
nativeView.setHeight(50);
/* -- Android */
popup.showPopup(anchor: View | nativeView , view: View | nativeView);
}
API
构造函数
Popup(options: PopupOptions)
构造函数示例
import { Popup, PopupOptions } from "nativescript-popup";
const opts: PopupOptions = {
backgroundColor: "white" | "#fff",
height: 100,
width: 100,
unit: "dp" | "px" | "%",
elevation: 10, // android only
borderRadius: 25 // android only
};
const popup = new Popup(opts);
弹出框方法
方法 | 描述 |
---|---|
showPopup(source: any, view: any): Promise |
显示弹出框,锚定于 source 参数,并将 view 参数作为弹出框内容。 view 参数可以是原生 Android/iOS 视图、NativeScript 视图或指向 app 目录下模板的字符串路径。 |
hidePopup(data?: any): Promise |
隐藏弹出框并从视图层次中移除。 |
许可证
Apache 许可证第 2 版,2004 年 1 月