惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
G
Google Developers Blog
B
Blog
Engineering at Meta
Engineering at Meta
阮一峰的网络日志
阮一峰的网络日志
The Register - Security
The Register - Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 叶小钗
The Cloudflare Blog
The Hacker News
The Hacker News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
雷峰网
雷峰网
F
Fortinet All Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
A
About on SuperTechFans
量子位
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
H
Help Net Security
Help Net Security
Help Net Security
P
Palo Alto Networks Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Troy Hunt's Blog
W
WeLiveSecurity
V
Vulnerabilities – Threatpost
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
Apple Machine Learning Research
Apple Machine Learning Research
Scott Helme
Scott Helme
N
News | PayPal Newsroom
AWS News Blog
AWS News Blog
D
DataBreaches.Net
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
腾讯CDC
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
TaoSecurity Blog
TaoSecurity Blog
GbyAI
GbyAI
Y
Y Combinator Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
Docker

博客园 - 瑞雪年

开始使用 Xamarin.Forms.Platform.Avalonia Git仓库迁移命令 .NET Core也可以使用MongoDB了 ng2-timesheet, 一个timesheet.js的angular2复制版 Angular 2 + Electron 开发web和桌面应用 Xamarin.Forms.Platform.Perspex, Xamarin Forms 的 Perspex(号称下一代WPF) 实现 Visual Studio Xamarin编译Android项目出错的解决办法 Salesforce + AngularJS + Bootstrap NativeScript 也能开发桌面应用 (nativescript-dotnet-runtime) iOS集成丁香园DXY OAuth 登陆 swift代码示例 WinObjC?这是什么鬼? 如何禁用Marlin温度保护 React Native也正式发布了 微信企业号 CoreCLR 在 Linux 下编译成功 Swift 对比学习 (二) Swift 对比学习 (一) 重量级Orchard模块发布 - 模块生成工具RaisingStudio.ModuleGenerator coding.net
用javascript写Android和iOS naitve应用,实在炫酷。
瑞雪年 · 2015-03-08 · via 博客园 - 瑞雪年

关注NativeScript有一段时间了,说好了的三月发第一个Beta版,终于发布了。

// declare the extended NativeScriptActivity functionality
var extendsObject = {
    onCreate: function(savedState){
        // call the base NativeScriptActivity.onCreate method
        // the "this" variable points to a NativeScriptActivity instance
        this.super.onCreate(savedState);

        // create a button and set it as the main content
        var button = new android.widget.Button(this);
        button.setText("Hello World");

        this.setContentView(button);
    }
}

// pass the extends object to create a new NativeScriptActivity instance
var mainActivity = com.tns.NativeScriptActivity.extends(extendsObject);

var applicationInitObject = {
    getActivity: function(intent) {
        // this method is called whenever a new instance of NativeScriptActivity is about to be created
        return mainActivity;
    },
    onCreate: function() {
        // This is the first method called. Called from the android.app.Application.onCreate method.
    } 
}

// The NativeScriptRuntime exposes the app object within the global context
app.init(applicationInitObject);

如上面代码,用javascript创那建一个Android的Activity,是不是很炫酷!

当然也可以写iOS native应用,这还不是最炫酷的,更炫酷的是,它还提供了一套“公共的”api,和一套可以用xml描述的ui控件库,可以这样定义界面,并在不同的平台下生成相应用本地控件。

<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
  <StackLayout>
    <Label text="Tap the button" cssClass="title"/>
    <Button text="TAP" tap="{{ tapAction }}" />
    <Label text="{{ message }}" cssClass="message" textWrap="true"/>
    <Button text="test button"/>
  </StackLayout>
</Page>

它还支持“数据绑定”,这你敢信?!

上样例: