【问题标题】:(options) should be type Object, but it was type number with value 2(options) 应该是 Object 类型,但它是类型号,值为 2
【发布时间】:2014-05-01 19:09:57
【问题描述】:

我在尝试使用 $goQuery 功能时遇到一个奇怪的错误。这是我的代码:

 var options = "{sort: null, limit: null}";
 var expr = "{userName: 'asdf'}";
 $scope.person = $goQuery('person',expr, options).$sync();

我收到以下错误消息:

Link to Error Message Image

我尝试将变量转换为 JSON.parse 对象,但这也不起作用。

【问题讨论】:

    标签: goinstant goangular


    【解决方案1】:

    您需要传递对象本身,而不是传递字符串文字。除此之外,您还需要为sortlimit 提供有效值。例如,使用您发布的代码:

    var options = { sort: { 'userName': 'asc' }, limit: 5 };
    var expr = {userName: 'asdf'};
    $scope.person = $goQuery('person',expr, options).$sync();
    

    【讨论】:

      【解决方案2】:

      好的,我开始工作了。我尝试了对象直接与字符串:

      $scope.person = $goQuery('person', { userName: $scope.person.findme }, { sort: { 'userName': 'asc' }, limit: 1 }).$sync();
      

      【讨论】:

        猜你喜欢
        • 2021-09-11
        • 1970-01-01
        • 2021-10-17
        • 2019-12-27
        • 1970-01-01
        • 1970-01-01
        • 2018-09-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多