Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

组件中有子组件是列表时,初始值为空在初始化时会报错导致该组件失效问题的解决 #411

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/wepy/src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ export default class {

let bindfor = binded.for, binddata = $parent;
bindfor.split('.').forEach(t => {
binddata = binddata[t];
if (binddata[t]){
binddata = binddata[t];
}else{
binddata = [{}];
}
});
repeatKey = Object.keys(binddata)[0];

Expand Down Expand Up @@ -270,7 +274,11 @@ export default class {
if (typeof(binded) === 'object') {
let bindfor = binded.for, binddata = $parent;
bindfor.split('.').forEach(t => {
binddata = binddata[t];
if (binddata[t]){
binddata = binddata[t];
}else{
binddata = [{}];
}
});

val = binddata[index];
Expand Down