zlgopen / awtk-mvvm

Model-View-ViewModel for AWTK
GNU Lesser General Public License v2.1
88 stars 27 forks source link

combo_box控件在窗口打开时其`selected_index`属性总为0而不与模型的一致 #33

Open ufbycd opened 2 years ago

ufbycd commented 2 years ago
<window tr_text="General Settings" anim_hint="htranslate" v-model="general_settings">
...
<combo_box  readonly="true" options="Chinese;English;" v-data:value="{language_id}"/>
...
</window>
general_settings_t* general_settings_create(void) {
  general_settings_t* general_settings = TKMEM_ZALLOC(general_settings_t);
  return_value_if_fail(general_settings != NULL, NULL);

  general_settings->language_id = 1;

  return general_settings;
}

打开窗口时,combo_box总是显示第0个选项而不跟模型的一致。

而将模型绑定到selected_index上:

<combo_box  readonly="true" options="Chinese;English;" v-data:selected_index="{language_id}"/>

打开窗口时,combo_box显示的选项而跟模型的一致;但操作UI改变选项后,模型属性language_id没有跟随UI变化。