mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
[bugfix] fix eslint error
This commit is contained in:
parent
37ef6d1d51
commit
496abba257
@ -34,24 +34,24 @@ module.exports = Behavior({
|
||||
},
|
||||
|
||||
methods: {
|
||||
bindgetuserinfo({ detail = {} } = {}) {
|
||||
this.triggerEvent('getuserinfo', detail);
|
||||
bindgetuserinfo(event = {}) {
|
||||
this.triggerEvent('getuserinfo', event.detail || {});
|
||||
},
|
||||
|
||||
bindcontact({ detail = {} } = {}) {
|
||||
this.triggerEvent('contact', detail);
|
||||
bindcontact(event = {}) {
|
||||
this.triggerEvent('contact', event.detail || {});
|
||||
},
|
||||
|
||||
bindgetphonenumber({ detail = {} } = {}) {
|
||||
this.triggerEvent('getphonenumber', detail);
|
||||
bindgetphonenumber(event = {}) {
|
||||
this.triggerEvent('getphonenumber', event.detail || {});
|
||||
},
|
||||
|
||||
bindopensetting({ detail = {} } = {}) {
|
||||
this.triggerEvent('opensetting', detail);
|
||||
bindopensetting(event = {}) {
|
||||
this.triggerEvent('opensetting', event.detail || {});
|
||||
},
|
||||
|
||||
binderror({ detail = {} } = {}) {
|
||||
this.triggerEvent('error', detail);
|
||||
binderror(event = {}) {
|
||||
this.triggerEvent('error', event.detail || {});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,15 +1,12 @@
|
||||
const nativeBehaviors = require('./behaviors');
|
||||
const classnames = require('../common/classnames');
|
||||
|
||||
const observer = function () {
|
||||
const observer = function() {
|
||||
this.setClasses();
|
||||
};
|
||||
|
||||
Component({
|
||||
externalClasses: [
|
||||
'custom-class',
|
||||
'loading-class'
|
||||
],
|
||||
externalClasses: ['custom-class', 'loading-class'],
|
||||
|
||||
behaviors: [nativeBehaviors],
|
||||
|
||||
@ -60,17 +57,13 @@ Component({
|
||||
setClasses() {
|
||||
const { type, size, plain, disabled, loading, block } = this.data;
|
||||
this.setData({
|
||||
classes: classnames(
|
||||
`van-button--${type}`,
|
||||
`van-button--${size}`,
|
||||
{
|
||||
'van-button--block': block,
|
||||
'van-button--plain': plain,
|
||||
'van-button--loading': loading,
|
||||
'van-button--disabled': disabled,
|
||||
'van-button--untapable': disabled || loading
|
||||
}
|
||||
)
|
||||
classes: classnames(`van-button--${type}`, `van-button--${size}`, {
|
||||
'van-button--block': block,
|
||||
'van-button--plain': plain,
|
||||
'van-button--loading': loading,
|
||||
'van-button--disabled': disabled,
|
||||
'van-button--untapable': disabled || loading
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -11,15 +11,15 @@ Component({
|
||||
},
|
||||
|
||||
data: {
|
||||
elementUpdateTimeout: 0
|
||||
elementUpdateTimeout: 0
|
||||
},
|
||||
|
||||
methods: {
|
||||
updateChildren(childPath) { // 把checkbox标记为在group中,设置不同样式
|
||||
let elements = this.getRelationNodes(childPath);
|
||||
const elements = this.getRelationNodes(childPath);
|
||||
|
||||
elements.forEach((checkbox, index) => {
|
||||
checkbox.updateData({ isInGroup: true});
|
||||
checkbox.updateData({ isInGroup: true });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ Component({
|
||||
return {
|
||||
isInGroup: false,
|
||||
isInCell: false
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
@ -31,8 +31,8 @@ Component({
|
||||
|
||||
const checked = !this.data.checked;
|
||||
|
||||
this.triggerEvent('change', checked)
|
||||
this.setData({ checked })
|
||||
this.triggerEvent('change', checked);
|
||||
this.setData({ checked });
|
||||
},
|
||||
|
||||
updateData(data) {
|
||||
|
@ -1,76 +0,0 @@
|
||||
// 从事件对象中解析得到 componentId
|
||||
// 需要在元素上声明 data-component-id
|
||||
function extractComponentId(event = {}) {
|
||||
const { dataset: { componentId } } = event.currentTarget || {};
|
||||
return componentId;
|
||||
}
|
||||
|
||||
/*
|
||||
注:默认合并所有生命周期函数
|
||||
配置合并指定的生命周期 or 忽略指定字段
|
||||
const extend = extendCreator({
|
||||
life: ['onLoad', 'onPullDownRefresh'],
|
||||
exclude: ['binder']
|
||||
});
|
||||
|
||||
Page(extend({}, {
|
||||
onLoad() {},
|
||||
...
|
||||
}));
|
||||
*/
|
||||
|
||||
const LIFE_CYCLE = ['onLoad', 'onReady', 'onShow', 'onHide', 'onUnload', 'onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onPageScroll'];
|
||||
|
||||
const extendCreator = (config = {}) => {
|
||||
const {
|
||||
life = LIFE_CYCLE,
|
||||
exclude = []
|
||||
} = config;
|
||||
|
||||
const excludeList = exclude.concat(LIFE_CYCLE.map(getFuncArrayName));
|
||||
|
||||
if (!Array.isArray(life) || !Array.isArray(exclude)) throw new Error('Invalid Extend Config');
|
||||
let lifeCycleList = life.filter(item => LIFE_CYCLE.indexOf(item) >= 0);
|
||||
return function extend(target, ...objList) {
|
||||
objList.forEach((source) => {
|
||||
if (source) {
|
||||
let keys = Object.keys(source);
|
||||
keys.forEach((key) => {
|
||||
let value = source[key];
|
||||
if (excludeList.indexOf(key) >= 0) return;
|
||||
if (lifeCycleList.indexOf(key) >= 0 && typeof value === 'function') {
|
||||
let funcArrayName = getFuncArrayName(key);
|
||||
if (!target[funcArrayName]) {
|
||||
target[funcArrayName] = [];
|
||||
if (target[key]) {
|
||||
target[funcArrayName].push(target[key]);
|
||||
}
|
||||
target[key] = function (...rest) {
|
||||
target[funcArrayName].forEach(func => func.apply(this, rest));
|
||||
};
|
||||
}
|
||||
|
||||
if (source[funcArrayName]) {
|
||||
// 经过生命周期合并的组件直接整合函数列表
|
||||
target[funcArrayName].push(...source[funcArrayName]);
|
||||
} else {
|
||||
// 添加生命周期函数进入函数列表
|
||||
target[funcArrayName].push(value);
|
||||
}
|
||||
} else {
|
||||
target[key] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return target;
|
||||
};
|
||||
};
|
||||
|
||||
const getFuncArrayName = name => `__$${name}`;
|
||||
|
||||
module.exports = {
|
||||
extractComponentId,
|
||||
extend: Object.assign,
|
||||
extendCreator
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
Component({
|
||||
externalClasses: [
|
||||
'custom-class',
|
||||
'custom-class'
|
||||
],
|
||||
|
||||
properties: {
|
||||
|
@ -38,15 +38,19 @@ Component({
|
||||
|
||||
methods: {
|
||||
// 当一个子项被选择时
|
||||
onItemSelect({ currentTarget = {} }) {
|
||||
const { dataset: data = {} } = currentTarget;
|
||||
this.triggerEvent('itemclick', { ...(data.item || {}) });
|
||||
onItemSelect(event) {
|
||||
const {
|
||||
dataset = {}
|
||||
} = event.currentTarget || {};
|
||||
this.triggerEvent('itemclick', { ...(dataset.item || {}) });
|
||||
},
|
||||
|
||||
// 当一个导航被点击时
|
||||
handleNavClick({ currentTarget = {} }) {
|
||||
const { dataset: data = {} } = currentTarget;
|
||||
this.triggerEvent('navclick', { index: data.index });
|
||||
handleNavClick(event) {
|
||||
const {
|
||||
dataset = {}
|
||||
} = event.currentTarget || {};
|
||||
this.triggerEvent('navclick', { index: dataset.index });
|
||||
},
|
||||
|
||||
// 更新子项列表
|
||||
@ -62,7 +66,7 @@ Component({
|
||||
updateMainHeight() {
|
||||
const maxHeight = Math.max(this.data.items.length * ITEM_HEIGHT, this.data.subItems.length * ITEM_HEIGHT);
|
||||
|
||||
this.setData({ mainHeight: Math.min(maxHeight, this.data.maxHeight) })
|
||||
this.setData({ mainHeight: Math.min(maxHeight, this.data.maxHeight) });
|
||||
},
|
||||
|
||||
// 更新子项列表高度,根据可展示的最大高度和当前子项列表的高度决定
|
||||
|
Loading…
x
Reference in New Issue
Block a user