I'm running this code:
<template>
<div>
<text onclick="log(items[0])">outside the loop</text>
<div repeat="item in items">
<text onclick="log(item)">{{item}}</text>
</div>
</div>
</template>
<script>
module.exports = {
data: {
items: ['foo']
},
methods: {
log: function(item) {
console.log(item);
}
}
}
</script>
When I click the "outside the lop", I see foo
, but when I click the "foo", I see undefined
. How could I pass the loop variable into the event handler?
This demo is ok in native code environment(I test it using iOS WeexSDK). Maybe it is a bug in browser.
By the way, you can use vuejs grammar in latest WeexSDK and it's no problem with loop variable.