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 2019/04/22 02:42:33 UTC

[GitHub] [incubator-weex] chenjuyu opened a new issue #2339: Component 扩展 方法不生效,使用ref

chenjuyu opened a new issue #2339: Component 扩展 方法不生效,使用ref
URL: https://github.com/apache/incubator-weex/issues/2339
 
 
   weex  -v : v1.3.11 
    - weex-debugger : v1.2.8
    - weex-builder : v0.4.0
    - weex-previewer : v1.5.1
   
   weexSDK:0.20.0 
   
   android Code 
   public class Html5Component extends WXComponent<WebView> {
   ......
      @RequiresApi(api = Build.VERSION_CODES.KITKAT)
       @JSMethod
       public void executeJsFunction(String functionName, String param, final JSCallback callback){
           System.out.println("已经执行到这个方法了!!");
     }
   }
   ----------------------------
   weex vue code
   
   <template>
       <div style="width:750px">
           <head :rightText="rightText" title="多颜色"  @rightClick="rightClick"></head>
           <webView ref="myWeb" @newEvent="newEvent" path="http://192.168.1.104:8080/XXX/common.do?testwebview&test=asssssss" @finish="htmlFinish" style="width: 720px; height:600px;align-items: center;justify-content:center">
           </webView>
           <div>
               <richText tel="12305" style="width:200;height:100">12305</richText>
           </div>
        <div style="background-color: orange;position: fixed;right: 0;bottom: 0;width: 750px;height: 80px;align-items: center;justify-content:center">
            <text style="font-size: 30px" @click="excuJS">提交</text>
        </div>
    
       </div>
   
   </template>
   
   `
   <script>
       const  pref=weex.requireModule('pref');
       var modal=weex.requireModule('modal');
       const webview = weex.requireModule('webview');
       export default {
           data() {
            return {
                name: "webView",
                url:'http://192.168.1.104:8080/FPOS/common.do?testwebview&test=asssssss',
                msg:'rrrr'
    
            }
           },methods: {
               onLoad(p){
    
               },
               htmlFinish(){//pref.getString('ip')+'
    
                   modal.alert({message:'界面加载完成'});
                   //this.html=pref.getString('ip')+'/common.do?testwebview'+'&test=asssssss'
                   //this.newEvent()
               },
               newEvent(e){
                   //e.data即为HTML传来的值
                   this.msg=e
                   modal.alert({message:e});
               },excuJS(e){//第二个参数 传到HTML的数据
                   this.$refs.myWeb.executeJSFunction('save','',
                 (res)=>{
                       //执行完成的回调
                     //this.alert(res)
                   })
    
               }
           },created(){
              // this.url='http://192.168.1.104:8080/FPOS/common.do?testwebview&test=asssssss'
              // this.excuJS()
              // this.$refs.myWeb.executeJSFunction("save",'',(res)=>{
               //    this.alert(res)
               //});
           }
       }
   </script>
   `
   点击提交 时  
   提示 ,后面打印,并没有运行到 android端方法里面
   this.$refs.myWeb.executeJSFunction  not a function  ,not run in to android function 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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