// components/newPicker/newPicker.js import { postApi } from "../../apis/api" import { debounce } from "../../utils/utils" Component({ properties: { url: { type: String }, params: { type: Object }, inputStyle: { type: String }, spTop: { type: String }, spHeight: { type: String, value: "0rpx" }, disabled: { type: Boolean }, value: { type: String || Number }, label: { type: String }, placeholder: { type: String }, arrow: { type: Boolean, value: true } }, data: { arr: [], visable: false, isLoading: false, isInit: true, index: -1 }, methods: { _getList: debounce(async function (e) { this.setData({ isInit: false }) let res = await postApi(this.data.url, { ...this.data.params, term: e.detail.value }) this.setData({ arr: res.data.result }) }, 600), _selectItem(e) { let { label, value } = e.currentTarget.dataset this.triggerEvent('selectItem', { label, value, }) this.setData({ label: '', }) this.cancel() }, showModal() { this.setData({ visable: true, }) }, cancel() { this.setData({ visable: false, isInit: true, arr: [], index: -1 }) } }, options: { styleIsolation: 'isolated' } })