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

checkbox 组件在路由切换的时候报错 #1717

Closed
microacup opened this Issue Dec 13, 2016 · 12 comments

Comments

Projects
8 participants
@microacup

microacup commented Dec 13, 2016

官网例子Table带checkbox。Chrome下面出现此问题。IE没有。

三个页面,一个页面含有上述组件,另外两个没有,使用了vue-router,在切换的时候出现此问题。

	    store: function store() {
	      return this._checkboxGroup.value; // 这里undefined
	    }
@EdenSpark

This comment has been minimized.

Show comment
Hide comment
@EdenSpark

EdenSpark Dec 14, 2016

嗯,同样出现了此问题,多个地方使用都是这个情况,但checkbox的值可以获取到

EdenSpark commented Dec 14, 2016

嗯,同样出现了此问题,多个地方使用都是这个情况,但checkbox的值可以获取到

@QingWei-Li

This comment has been minimized.

Show comment
Hide comment
@QingWei-Li

QingWei-Li Dec 14, 2016

Member

可否给一个 demo?官网的例子没有出现类似问题

Member

QingWei-Li commented Dec 14, 2016

可否给一个 demo?官网的例子没有出现类似问题

@baiyaaaaa

This comment has been minimized.

Show comment
Hide comment
@baiyaaaaa

baiyaaaaa Dec 14, 2016

Contributor

官网例子没有出现问题呀

Contributor

baiyaaaaa commented Dec 14, 2016

官网例子没有出现问题呀

@hopkinson

This comment has been minimized.

Show comment
Hide comment
@hopkinson

hopkinson Dec 14, 2016

我也出现了。就是使用了带有checkbox的table时 切换路由出现了value undefined

hopkinson commented Dec 14, 2016

我也出现了。就是使用了带有checkbox的table时 切换路由出现了value undefined

@Leopoldthecoder

This comment has been minimized.

Show comment
Hide comment
@Leopoldthecoder

Leopoldthecoder Dec 14, 2016

Member

官网例子就有带有 checkbox 的 Table,但是切换路由时没有报错。所以还是需要各位提供一个 demo。

Member

Leopoldthecoder commented Dec 14, 2016

官网例子就有带有 checkbox 的 Table,但是切换路由时没有报错。所以还是需要各位提供一个 demo。

@yelingfeng

This comment has been minimized.

Show comment
Hide comment
@yelingfeng

yelingfeng Dec 14, 2016

我这也会莫名报个这个错

yelingfeng commented Dec 14, 2016

我这也会莫名报个这个错

@yelingfeng

This comment has been minimized.

Show comment
Hide comment
@yelingfeng

yelingfeng Dec 14, 2016

退回1.0.5 不报错了

yelingfeng commented Dec 14, 2016

退回1.0.5 不报错了

@microacup

This comment has been minimized.

Show comment
Hide comment
@microacup

microacup Dec 15, 2016

代码改了一堆,demo还没准备好,提供一个绕路思路吧,参考http://microacup.meiqiu.me/2016/12/14/vue-element/ 第一个问题

microacup commented Dec 15, 2016

代码改了一堆,demo还没准备好,提供一个绕路思路吧,参考http://microacup.meiqiu.me/2016/12/14/vue-element/ 第一个问题

@baiyaaaaa baiyaaaaa changed the title from checkbox.js?7d76:162 Uncaught TypeError: Cannot read property 'value' of undefined(…) to checkbox 组件在路由切换的时候报错 Dec 16, 2016

@baiyaaaaa baiyaaaaa added the type: bug label Dec 16, 2016

@baiyaaaaa

This comment has been minimized.

Show comment
Hide comment
@baiyaaaaa

baiyaaaaa Dec 19, 2016

Contributor

@microacup 能提供一个demo么

Contributor

baiyaaaaa commented Dec 19, 2016

@microacup 能提供一个demo么

@donlzx

This comment has been minimized.

Show comment
Hide comment
@donlzx

donlzx Dec 19, 2016

Had the same issue. Below are some analysis and a possible fix.

In get() function of the the "model" computed property in checkbox.vue

get() {
  return this.isGroup ? this.store : this.value;
}

Because this.isGroup is a computed property and may be cached, while this.isGroup is true, this._checkboxGroup may already be null (destroyed).

The following fix for the store() function works for me:

store() {
  return this._checkboxGroup ? this._checkboxGroup.value : this.value;
}

donlzx commented Dec 19, 2016

Had the same issue. Below are some analysis and a possible fix.

In get() function of the the "model" computed property in checkbox.vue

get() {
  return this.isGroup ? this.store : this.value;
}

Because this.isGroup is a computed property and may be cached, while this.isGroup is true, this._checkboxGroup may already be null (destroyed).

The following fix for the store() function works for me:

store() {
  return this._checkboxGroup ? this._checkboxGroup.value : this.value;
}
@baiyaaaaa

This comment has been minimized.

Show comment
Hide comment
@baiyaaaaa

baiyaaaaa Dec 20, 2016

Contributor

@donlzx thanks! seems to be the problem and i will fix it

Contributor

baiyaaaaa commented Dec 20, 2016

@donlzx thanks! seems to be the problem and i will fix it

@baiyaaaaa baiyaaaaa referenced this issue Dec 20, 2016

Merged

fix checkbox isGroup bug in computed cached #1860

4 of 4 tasks complete
@baiyaaaaa

This comment has been minimized.

Show comment
Hide comment
@baiyaaaaa

baiyaaaaa Dec 20, 2016

Contributor

@microacup @EdenSpark 可以在1.0.8的版本验证下,今天会发版,谢谢

Contributor

baiyaaaaa commented Dec 20, 2016

@microacup @EdenSpark 可以在1.0.8的版本验证下,今天会发版,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment