判断参数是否是其中之一
- 正常写法
```javascript
function oneOf(value, validList) {
for (let i = 0; i < validList.length; i++) {
if (value === validList[i]) {
} } return false; }return true;
validator(value) { return oneOf(value, [“small”, “large”, “default”]); },
- 高级
```javascript
function oneOf(value, validList) {
return validList.some((item) => {
return item === value;
});
}