gpt4 book ai didi

javascript - 纸张下拉菜单/纸张列表框 : how to get the value in the request

转载 作者:行者123 更新时间:2023-11-28 03:48:14 27 4
gpt4 key购买 nike

我在纸张下拉菜单中有纸张列表框元素,项目的值与标签不同。这是示例

<paper-dropdown-menu label="Gender" name="gender" required error-message="Gender is required">
<paper-listbox slot="dropdown-content" attr-or-property-name="value">
<paper-item value="M">Male</paper-item>
<paper-item value="F">Female</paper-item>
</paper-listbox>
</paper-dropdown-menu>

但是在帖子中,给出的是标签而不是项目的值

您知道在请求中包含 gender=Mgender=F 吗?

最佳答案

这是可能的,尽管您必须向 paper-listbox 添加一个 id 属性并进行一些挖掘:

<dom-module id="item-value-demo">
<template>
<style></style>
<paper-dropdown-menu label="Gender" name="gender" required error-message="Gender is required">
<paper-listbox id="gender" slot="dropdown-content" attr-or-property-name="value">
<paper-item value="M">Male</paper-item>
<paper-item value="F">Female</paper-item>
</paper-listbox>
</paper-dropdown-menu>
</template>
<script>
class ItemValueDemo extends Polymer.Element {
static get is() { return 'item-value-demo'; }

ready() {
super.ready();
this.$.gender.addEventListener('selected-item-changed', e => { this._genderOption(e) });
}

_genderOption(e) {
const value = e.target.selectedItem;
if (value) {
console.log(value.attributes["value"].value);
}
}
}
customElements.define(ItemValueDemo.is, ItemValueDemo);
</script>
</dom-module>

<item-value-demo></item-value-demo>

参见this pen

关于javascript - 纸张下拉菜单/纸张列表框 : how to get the value in the request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48262843/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com