Last active
July 16, 2017 04:15
-
-
Save hjkcai/eddb62be911e7e66d18a65d06d783c1d to your computer and use it in GitHub Desktop.
嵌套组件中同时出现wx:for和repeat会导致repeat中循环变量失效
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<view class="comp"> | |
<slot></slot> | |
</view> | |
</template> | |
<script> | |
import wepy from 'wepy' | |
export default class Comp extends wepy.component {} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<view> | |
<wrapper></wrapper> | |
</view> | |
</template> | |
<script> | |
import wepy from 'wepy' | |
import wrapper from './wrapper' | |
export default class Index extends wepy.page { | |
components = { | |
wrapper | |
} | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<view id="wrapper"> | |
<view id="for1"> | |
<view wx:for="{{ arr1 }}">{{ item }}</view> | |
</view> | |
<view id="for2"> | |
<repeat for="{{ arr2 }}"> | |
<comp>{{ item }}</comp> | |
</repeat> | |
</view> | |
</view> | |
</template> | |
<script> | |
import wepy from 'wepy' | |
import comp from './comp' | |
export default class Wrapper extends wepy.component { | |
components = { | |
comp | |
} | |
data = { | |
arr1: ['a', 'b', 'c'], | |
arr2: ['1', '2', '3'] | |
} | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<view id="wrapper"> | |
<view id="for1"> | |
<view wx:for="{{ arr1 }}" wx:for-item="for1Item" wx:for-index="for1Index">{{ for1Item }}</view> | |
</view> | |
<view id="for2"> | |
<repeat for="{{ arr2 }}"> | |
<comp>{{ item }}</comp> | |
</repeat> | |
</view> | |
</view> | |
</template> | |
<script> | |
import wepy from 'wepy' | |
import comp from './comp' | |
export default class Wrapper extends wepy.component { | |
components = { | |
comp | |
} | |
data = { | |
arr1: ['a', 'b', 'c'], | |
arr2: ['1', '2', '3'] | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment