Skip to content

小程序中 v-for 循环的items不支持方法调用 #2012

Closed
@torns

Description

小程序中 v-for 循环的items不支持方法调用,如:html<li v-for="n in even(set)">{{ n }}</li>中的even方法在web版会被执行,在小程序版就未被执行.

<ul v-for="set in sets">
  <li v-for="n in even(set)">{{ n }}</li>
</ul>

data: {
  sets: [[ 1, 2, 3, 4, 5 ], [6, 7, 8, 9, 10]]
},
methods: {
  even: function (numbers) {
    return numbers.filter(function (number) {
      return number % 2 === 0
    })
  }
}

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions