2017-07-18 153 views
0

我想知道是否有可能在聚合物火多重功能上点击或输入等多种功能 - 聚合物

例如使用时:

HTML (清单逐一)

<paper-input label="text please" on-input="funct1;funct2"></paper-input> 

JS

funct1 : function() { 
    code here to do something 
}, 

funct2 : function() { 
    code here to do something 
}, 

或........................

HTML (将它们分组)

<paper-input label="text please" on-input="allFuncts"></paper-input> 

JS

allFuncts : function() { 
    funct1; 
    funct2; 
}, 

funct1 : function() { 
    code here to do something 
}, 

funct2 : function() { 
    code here to do something 
}, 

回答

0

当然,在纯JS:

onclick='func1();func2()'; 
+0

onclick/oninput普通JS标签在聚合物中不起作用,它们被替换为点击和输入。所以这对我不起作用:-( – physicsboy

0

我找到了答案通过一些调查,通过询问同事。

最好是编写一个调用其他函数的函数,如果变量没有全局定义,请记住添加this.前缀。

HTML

<paper-input label="text please" on-input="allFuncts"></paper-input> 

JS

allFuncts : function() { 
    this.funct1(); <------------------ This is where I was going wrong 
    this.funct2();      needing the "this." before the 
             function call 
}, 

funct1 : function() { 
    code here to do something 
}, 

funct2 : function() { 
    code here to do something 
}, 

编辑

通过玩这个,我发现,你可以从顶部功能的传递变量通过声明t来调用函数在顶部函数中全局下摆(即,没有var在变量名前面)。不过,我相信这会导致代码中的不安全感。

allFuncts : function() { 
    /* var */ variableName = someVariable; 

    this.funct1(); 
    this.funct2(); 
} 

funct1 : function() { 
    // can use **variableName** within this function 
}