簡體   English   中英

流星調用-模板助手中的異常

[英]Meteor Call - Exception in template helper

我正在嘗試在客戶端中進行方法調用,但是我得到了

Exception in template helper: Error: Syntax error, unrecognized expression: https://www.example.com

我正在使用Meteor方法解析XML中的URL以獲取一些數據,所以我的變量是字符串URL

方法

 rank: function(postAttributes) {
    check(postAttributes, {
      url: String
    });
    var alexa = require('alexarank');
    var alexaSync = Meteor.wrapAsync(alexa);
    var result = alexaSync({url: postAttributes.url});
    return result.rank;
  }

客戶電話

function() {
    var a = document.createElement('a');
    a.href = this.url;
     var post = {
      url: $(a.href)
    };
    Meteor.call('rank', post, function(error, result) {
      // display the error to the user and abort
      if (error)
        return throwError(error.reason);
      // show this result but route anyway
      return result;
    });
  }

任何想法?

也許$(a.href)沒有返回字符串,並且模板執行的url就像是javascript代碼一樣。

嘗試使用:

url: '' + $(a.href)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM