// components/localPicker/localPicker.js import { postApi } from "../../apis/api" Component({ properties: { url: { type: String }, params: { type: Object }, inputStyle: { type: String }, disabled: { type: Boolean }, value: { type: String || Number }, label: { type: String }, placeholder: { type: String }, autoGet: { type: Boolean } }, data: { arr: [], index: '' }, lifetimes: { ready() { if (this.data.autoGet) { this._getList() } } }, methods: { async _getList(params) { let res = await postApi(this.data.url, { ...this.data.params, ...params, term: this.data.label }) this.setData({ arr: res.data.result, label: '' }) }, _selectItem(e) { let index = e.detail.value let { value: label, key: value } = this.data.arr[index] this.setData({ label, value, index, }) this.triggerEvent('selectItem', { label, value }) }, _handlerOne() { this.setData({ arr: [], visable: true }) }, }, options: { styleIsolation: 'isolated' } })