Skip to content

Commit 5d4acd2

Browse files
committed
fix:自定义表单组件异常 ReferenceError: initialValue is not defined #1190
1 parent f07375e commit 5d4acd2

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

components/upload/UploadList.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Progress from '../progress';
77
import classNames from 'classnames';
88
import { UploadListProps } from './interface';
99

10-
const isImageFileType = (type) => !!type && type.indexOf('image/') === 0;
10+
const isImageFileType = type => !!type && type.indexOf('image/') === 0;
1111
// https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL
1212
const previewFile = (file, callback) => {
1313
if (!isImageFileType(file.type)) {

components/upload/__tests__/uploadlist.test.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,11 @@ describe('Upload List', () => {
339339
it('should generate thumbUrl from file', done => {
340340
const handlePreview = jest.fn();
341341
const newFileList = [...fileList];
342-
const newFile = { ...fileList[0], uid: -3, originFileObj: new File([], 'xxx.png', { type: 'image/png' }) };
342+
const newFile = {
343+
...fileList[0],
344+
uid: -3,
345+
originFileObj: new File([], 'xxx.png', { type: 'image/png' }),
346+
};
343347
delete newFile.thumbUrl;
344348
newFileList.push(newFile);
345349
const props = {
@@ -358,7 +362,11 @@ describe('Upload List', () => {
358362
};
359363
const wrapper = mount(Upload, props);
360364
setTimeout(async () => {
361-
const newFile = { ...fileList[2], uid: -4, originFileObj: new File([], 'xxx.png', { type: 'image/png' }) };
365+
const newFile = {
366+
...fileList[2],
367+
uid: -4,
368+
originFileObj: new File([], 'xxx.png', { type: 'image/png' }),
369+
};
362370
wrapper.setProps({
363371
defaultFileList: newFileList.push(newFile),
364372
});

components/vc-form/src/createBaseForm.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function createBaseForm(option = {}, mixins = []) {
194194
!(
195195
!slotHasProp(fieldElem, valuePropName) &&
196196
valuePropName in originalProps &&
197-
!(fieldOption && initialValue in fieldOption)
197+
!(fieldOption && 'initialValue' in fieldOption)
198198
),
199199
`${getComponentName(
200200
fieldElem.componentOptions,

0 commit comments

Comments
 (0)