Vue: Custom vue filter always having a vue warn error not defined

Created on 8 Dec 2016  路  3Comments  路  Source: vuejs/vue

Im using filters for chunking arrays but errors pops up like this one

image

Vue.filter('chunk',(array, length) => {
  return _.chunk(array,length);
});

and use it to my component

    <transition-group v-for="data in dataList | chunk(3)"
                      class="row"
                      enter-active-class="animated bounceInRight"
                      leave-active-class="animated bounceOutRight">
      <div class="col-xs-12 col-md-4" :key="data['.key']">
        <md-card md-with-hover>
          <slot :data="data"></slot>
        </md-card>
      </div>
    </transition-group>
need repro

Most helpful comment

In 2.x filters only work in mustache interpolations and v-bind.

All 3 comments

The component seems to be lacking access to the filter.
Are you exporting a plain object inside card.vue? If you're doing something like export default Vue.component(...) or export default Vue.extend(...) then it's the cause of the problem.
If not, please follow the Issue Reporting Guidelines and provide a repo on github to reproduce the issue, thanks!

In 2.x filters only work in mustache interpolations and v-bind.

${} - can't access filter. Thank you @yyx990803(Evan You).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paulpflug picture paulpflug  路  3Comments

bfis picture bfis  路  3Comments

fergaldoyle picture fergaldoyle  路  3Comments

franciscolourenco picture franciscolourenco  路  3Comments

loki0609 picture loki0609  路  3Comments