简体   繁体   English

流星onRendered意外令牌=

[英]Meteor onRendered Unexpected token =

Am having an issue of using JQuery plugin in meteor template. 在流星模板中使用JQuery插件时遇到问题。 I tried this plugin. 我尝试了这个插件。

 <div id="listId">
  <ul class="list">
      // A bunch of items
  </ul>
  <ul class="pagination"></ul>
</div>

<script>
  var options = {
    valueNames: [ 'name', 'category' ],
    page: 3,
    plugins: [
      ListPagination({})
    ]
  };

  var listObj = new List('listId', options);
</script>

I put about javascript code in onRendered. 我在onRendered中放置了javascript代码。

Template.MyTemplate.onRendered({
    listObj = new List('listId', {
      valueNames: [ 'name', 'category' ],
      page: 3,
      plugins: [
        ListPagination({})
      ]
    });`enter code here`
});

But I am getting error. 但是我遇到了错误。

MyTemplate.js:2:13: Unexpected token =

You are passing object ({}) to onRendered function: 您正在将对象({})传递给onRendered函数:

Template.MyTemplate.onRendered({
    listObj = new List('listId', {
      valueNames: [ 'name', 'category' ],
      page: 3,
      plugins: [
        ListPagination({})
      ]
    });
});

You should pass function: 您应该传递函数:

Template.MyTemplate.onRendered(function() {
    listObj = new List('listId', {
      valueNames: [ 'name', 'category' ],
      page: 3,
      plugins: [
        ListPagination({})
      ]
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM