miniprogram/node_modules/@vant/weapp/dist/picker/index.js
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
import { VantComponent } from '../common/component';
import { pickerProps } from './shared';
VantComponent({
classes: ['active-class', 'toolbar-class', 'column-class'],
props: Object.assign(Object.assign({}, pickerProps), { valueKey: {
type: String,
value: 'text',
}, toolbarPosition: {
type: String,
value: 'top',
}, defaultIndex: {
type: Number,
value: 0,
}, columns: {
type: Array,
value: [],
observer(columns = []) {
this.simple = columns.length && !columns[0].values;
if (Array.isArray(this.children) && this.children.length) {
this.setColumns().catch(() => { });
}
},
} }),
beforeCreate() {
Object.defineProperty(this, 'children', {
get: () => this.selectAllComponents('.van-picker__column') || [],
});
},
methods: {
noop() { },
setColumns() {
const { data } = this;
const columns = this.simple ? [{ values: data.columns }] : data.columns;
const stack = columns.map((column, index) => this.setColumnValues(index, column.values));
return Promise.all(stack);
},
emit(event) {
const { type } = event.currentTarget.dataset;
if (this.simple) {
this.$emit(type, {
value: this.getColumnValue(0),
index: this.getColumnIndex(0),
});
}
else {
this.$emit(type, {
value: this.getValues(),
index: this.getIndexes(),
});
}
},
onChange(event) {
if (this.simple) {
this.$emit('change', {
picker: this,
value: this.getColumnValue(0),
index: this.getColumnIndex(0),
});
}
else {
后面还有 76 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。