我有带有vaadin-combo-box的HTML表单,该项目的值来自参考查询。我成功设置了要保存到主数据中的值,但不幸的是,我仍然不知道如何设置onload的第一个值
我只是尝试了一下,但没有发现错误或没有显示
html:
<form id="form">
<div>[[data.id]]<input size="1" name="id" value$='[[data.id]]'></div>
<div>
<iron-ajax url="url" last-response="{{response}}" auto></iron-ajax>
<vaadin-combo-box selected-item="{{No}}" placeholder="Please select" items=[[response]]" ></vaadin-combo-box>
</div>
</form>
js:
ready(){
document.querySelectorAll('vaadin-combo-box').forEach(function(comboBox) {
document.querySelectorAll('vaadin-combo-box').value =
$(this.$.form).serializeJSON().regNo ;
});
}
答案 0 :(得分:0)
尝试这样的事情。
document.querySelectorAll('vaadin-combo-box').forEach(function(comboBox) {
//write all the options in combo box as an array and assign it to comboBox.items
comboBox.items = ["a","b","C"]; //This is an example array.
comboBox.value = $(this.$.form).serializeJSON().regNo;
});
但是如果整个页面中只有一个“ vaadin-combo-box”,那么
comboBox = document.querySelector('vaadin-combo-box')
//set all the options in combo box as an array and assign it to comboBox.items
comboBox.items = ["a","b","C"]; //This is an example array.
comboBox.value = $(this.$.form).serializeJSON().regNo;
有关更多详细信息,请选中https://vaadin.com/components/vaadin-combo-box/html-examples