Vue: v-model可能存在的BUG

Created on 2 Apr 2017  ·  2Comments  ·  Source: vuejs/vue

Version

2.2.6

Reproduction link

https://jsfiddle.net/duyang/5nmpyavb/2/

Steps to reproduce

注释代码中有说明,我写了一个正常版本的,也写了一个BUG版本的(已经注释,开启即可,同时把正常版本注释掉)

What is expected?

JSFiddle示例说明了一切,希望两种写法都能够被支持,因为有些场景需要支持两种写法

What is actually happening?

JSFiddle示例说明了一切,v-model表达式使用三元表达式有些局限

Most helpful comment

This is a wontfix - v-model expression must be something that is "assignable".

For your use case, it's much cleaner to have a top level v-if / v-else instead of multiple ternaries.

All 2 comments

Thanks for reporting, it looks like a problem with the codegen. The code generated is isParentMenu ? buttons[0].name : buttons[0].sub_button[0].name = $event.target.value for the input event which will not set the value.

This is a wontfix - v-model expression must be something that is "assignable".

For your use case, it's much cleaner to have a top level v-if / v-else instead of multiple ternaries.

Was this page helpful?
0 / 5 - 0 ratings