微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将对象传递给此函数时,我的 Meteor.call 语法应该是什么?

如何解决将对象传递给此函数时,我的 Meteor.call 语法应该是什么?

我收到了这条指令:

Metor.call("templates.setAsPublicTemplate",itemId: string,description: string,imgurL: string,language: string,order?: number,)

我在其中添加了此信息,但看起来不对,当然不起作用,我该如何传递此功能

Meteor.call("templates.setAsPublicTemplate",{
    itemId: "nbgcnNr4YmXwMWMjP",description: "this is the description of my template space bla bla bla",imgurL: "https://res.cloudinary.com/deruwllkv/image/upload/v1625753766/shopping.png",language: "en",order: 0,});

解决方法

看起来像你得到的 TypeScript 原型。它告诉您冒号后函数参数的类型,但除此之外,您可以像其他所有 javascript 函数一样调用它:

Meteor.call("templates.setAsPublicTemplate","nbgcnNr4YmXwMWMjP","this is the description of my template space bla bla bla","https://res.cloudinary.com/deruwllkv/image/upload/v1625753766/shopping.png","en",0);
,

我自己从来没有使用过这个库,所以我不能保证这是正确的调用方式,但我相信你应该这样调用:

function textTostring(text: string) => void;

文档的简单示例:

假设您有以下函数文档:

textToString

这意味着函数 text 接受 1 个名为 string 的参数(因此您知道它代表什么)并且类型为 function meteorCall(data) { return Meteor.call("templates.setAsPublicTemplate",data.itemId,data.description,data.imgURL,data.language,data.order); } (因此您知道要传递的值的类型) ,然后它最终返回一个数字值。

更具体

如果你想使用一个对象来调用它,以便你手动命名每个属性,你可以像这样创建一个包装函数:

meteorCall({
    itemId: "nbgcnNr4YmXwMWMjP",description: "this is the description of my template space bla bla bla",imgURL: "https://res.cloudinary.com/deruwllkv/image/upload/v1625753766/shopping.png",language: "en",order: 0,});

你会称之为:

protected boolean fillColumnWithPlayerColor(VBox col) {

    ObservableList<Node> discs = col.getChildren();

    for (int i = discs.size() - 1; i >= 0; i--) {
        Circle circle = (Circle) discs.get(i);

        if (circle.getFill().equals(Color.WHITE)) {
            if (i > 0) {
                for (int j = 0; j < i; j++) {
                    Circle prevCircle = (Circle) discs.get(j);//Assigning the current disc to player color
                    prevCircle.setFill(playerColor); //playerColor -> Color chosen by player
                    try {
                        Thread.sleep(800); //Delay for display
                        prevCircle.setFill(Color.WHITE); //Setting the color back to White
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                }
            }
            circle.setFill(playerColor);
            return true;

        }

    }

    return false;

}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。