You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2018/10/19 07:49:41 UTC

[GitHub] chinabrant opened a new issue #1649: how to use js service?

chinabrant opened a new issue #1649: how to use js service?
URL: https://github.com/apache/incubator-weex/issues/1649
 
 
   My js service register codeļ¼š
   ```objective-c
   NSString *path = [[NSBundle mainBundle] pathForResource:@"utils_service" ofType:@"js"];
       NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
       
       [WXSDKEngine registerService:@"utilsService" withScript:content withOptions:@{ @"serviceName": @"utilsService" }];
   ```
   
   JS Service code:
   ```javascript
   service.register("utilsService", {
      
       create: function (id, env, config) {
           return {
               NormalService: function (weex) {
                   var modal = weex.requireModule('modal')
                   return {
                       toast: function (title) {
                           modal.toast({ message: title })
                       },
   ...
   ```
   
   use code:
   var utilService = new service.normalService(weex) 
   
   error:
   service name not defined
   
   Question:
   Follow this [document](https://weex.apache.org/cn/references/js-service.html), i can't understand how to use JS Service.
   
   If i want to register more than one JS Service, what should i do? 
   
   Thanks.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services