我想做这样的事情,但它不以这种方式工作。 这是 xml 代码:
<image id="CustomerRadioButton" src="{{ CustomerRBSrc }}" class="RadioButton" tap="CustomerTypeRadioButtonOnTap('C')"/>
如何在js代码中获取这个参数?
最佳答案
您可以通过多种方法在 PAN(Plain Awesome Nativescript)应用程序中处理此问题。
您可以调用自定义函数,然后调用正确的函数,即按钮设置为:
CustomerTypeRadioButtonOnTapC = () { CustomerTypeRadioButtonOnTap('C'); }
您可以在图像上设置自定义属性 - 即
<image id="CustomerRadioButton" src="{{ CustomerRBSrc }}" class="RadioButton" tap="CustomerTypeRadioButtonOnTap" customerType="C"/>
然后
function CustomerTypeRadioButtonOnTab (args) {
console.log(args.object.customerType); // Should be "C"
}
关于javascript - 在nativescript中使用tap函数传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52135591/