本文整理匯總了TypeScript中antd.message.error方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript message.error方法的具體用法?TypeScript message.error怎麽用?TypeScript message.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類antd.message
的用法示例。
在下文中一共展示了message.error方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
response.json().then(json => {
try {
message.error("錯誤," + json['error'])
}catch(e){
message.error("發生錯誤")
}
})
示例2: state
(dispatch: Redux.Dispatch, state: ()=>any)=> {
let _state: QueryInterface = state().query_list;
if (_state.start && !_state.end) {
message.error("當指定開始時間時,必須同時指定結束時間");
return
}
if (_state.end && !_state.start) {
message.error("當指定結束時間時,必須同時指定開始時間");
return
}
if (_state.end < _state.start) {
message.error("結束時間不能小於開始時間");
return
}
const url = `/api/query/query-call-over/?${parse_data(_state.start, 'start')}${parse_data(_state.end, 'end')}department=${_state.current_department}`;
fetch(url, {
credentials: 'include',
method: 'get',
}).then(response=> {
if (response.status == 200) {
response.json().then((json)=> {
dispatch(UpdateListData(json))
})
} else {
response.json().then(json=>message.error(JSON.stringify(json)))
}
});
return
}
示例3: validateFile
export function validateFile(file: { type: string; size: number }): boolean {
// console.log(file);
const isImage = ['image/jpeg', 'image/png', 'image/gif'].indexOf(file.type) > -1;
const isLt20M = file.size / 1024 / 1024 < 20;
logger.log('[validateFile]', file, { isImage, isLt20M });
if (!isImage) {
message.error('You can only upload JPG/PNG/GIF file!');
}
if (!isLt20M) {
message.error('Image must smaller than 20MB!');
}
return isImage && isLt20M;
}
示例4: loginSaga
function* loginSaga({ payload: { username, password }, callback }) {
const auth: AuthState = yield select((state: RootState) => state.auth);
try {
const response = yield call(authProxy.login, username, password);
logger.log('[loginSaga]', 'response is', response);
// 切換用戶時更新操作區域,如果未來需要保存當前頁麵配置的話,應該將切換操作提出為單獨的 Saga
if (auth.username !== username) {
yield put(panesActions.closeAll());
}
if (callback) callback({ response });
const token = yield call(authProxy.extractToken, response.data);
yield put(authActions.loginSuccess(username, token));
message.info(`'${username}' login success`);
yield put(routerActions.toIndex());
} catch (error) {
logger.error('[loginSaga]', { error });
try {
if (callback != null) callback({ error });
} catch (e) {
logger.warn('[upsert] callback error', e, { e });
}
if (error.response) {
yield put(authActions.loginFailed(error.response));
message.error(toErrorMessage(error));
}
}
}
示例5: fetch
(dispatch:Redux.Dispatch, getState:()=>any)=> {
if(username.length>0 && password.length>0){
fetch('/api/scrapy/about-password/', {
credentials: 'include',
method: 'post',
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ password: password, username: username })
}).then(response => {
if (response.status == 200) {
message.success("成功更改了密碼")
dispatch(actions.change_password_modal(false))
} else {
response.json().then(json => {
try {
message.error("錯誤," + json['error'])
}catch(e){
message.error("發生錯誤")
}
})
}
})
}else{
message.error("用戶名或密碼字段不能為空")
}
}
示例6: loadModels
function* loadModels({ payload: { name, models } }: LoadModelsParams) {
const { token } = yield select((state: RootState) => state.auth);
if (token) {
try {
const {
[name]: { extras },
} = models;
logger.debug('[loadModels]', 'loading content', { name, extras });
message.loading(`loading content '${name}'...`);
const response = yield call(AppContext.adapters.models.loadModels, name, extras);
message.success(`load content '${name}' success`);
logger.log('[loadModels]', 'loaded content', { name, response });
yield put(
contentActions.loadModelsSuccess({
[name]: { data: response.data, loading: false },
}),
);
} catch (e) {
logger.warn('[loadModels]', { e });
message.error(toErrorMessage(e));
}
}
}
示例7:
(result: AxiosResponse<IResult<any, any>>) => {
if (result.data.errno !== 0) {
if (typeof result.data.errmsg === 'string') {
message.error(result.data.errmsg);
}
}
return Promise.resolve(result);
},
示例8:
UPDATE_DATE_RANGE: (state,
action: ActionMeta<{ end: moment.Moment, start: moment.Moment}, {}>) => {
if (action.error) {
message.error(`Error updating date range.`);
} else {
return Object.assign({}, state, action.payload);
}
},
示例9: dispatch
).then(response=> {
if (response.status === 404) {
dispatch(UpdateClassPlan(null));
} else if (response.status === 200) {
response.json().then(json=>dispatch(UpdateClassPlan(json)))
} else {
message.error('發生錯誤,錯誤碼為' + response.status)
}
})
示例10: catchError
catchError((error: AxiosResponse | undefined) => {
console.log(error);
if (error === undefined) {
return message.error('請求出錯');
}
this.error$ = of(error);
this.handleError();
return this.error$;
})