weixin_39700625
weixin_39700625
2021-01-11 20:11

Which percentage Do Nativescript-Vue cover Nativescript API engine?

Which percentage Do Nativescript-Vue cover Nativescript API engine?

该提问来源于开源项目:nativescript-vue/nativescript-vue

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • weixin_39700215 weixin_39700215 4月前

    Your issue has been tagged as low priority because it did not follow our issue guidelines.

    If you believe your issue should be higher priority please close this issue and create a new one using the issue helper.

    Thanks for your understanding.

    点赞 评论 复制链接分享
  • weixin_39869791 weixin_39869791 4月前

    Please clarify your question (even better on Slack/Discord) - not quite sure what you are asking!

    点赞 评论 复制链接分享
  • weixin_39700625 weixin_39700625 4月前

    Hi, I mean if all iOS or Android Api can be used with NativescriptVue.

    点赞 评论 复制链接分享
  • weixin_39869791 weixin_39869791 4月前

    Yes you can use any platform APIs directly in NativeScript (and NativeScript-Vue).

    For example in ObjC you would write the following:

    objc
    NSURL *url = [NSURL URLWithString:@"http://example.com"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [NSURLConnection sendAsynchronousRequest:request queue:nil completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        NSLog(@"request complete");
    }];
    

    And to write it in JavaScript in NativeScript, you would write:

    js
    var url = NSURL.URLWithString("http://example.com");
    var request = NSURLRequest.requestWithURL(url);
    NSURLConnection.sendAsynchronousRequestQueueCompletionHandler(request, null, function(response, data, connectionError) {
        console.log("request complete");
    });
    

    More details here: https://docs.nativescript.org/core-concepts/ios-runtime/Overview

    The same approach work with android as well, for example

    js
    var clickListener = android.view.View.OnClickListener({
        onClick: function (view) {
            // Do something on click
        }
    });
    

    Will create a native OnClickListener that works in js.

    Read more about the android runtime here: https://docs.nativescript.org/core-concepts/android-runtime/overview

    In most apps however, you wouldn't need to write code like that, only when you want to use an API that hasn't been wrapped/implemented in NativeScript - and even then, you will often find plugins that have done the work.

    点赞 评论 复制链接分享

相关推荐