UNPKG

1.05 kBJavaScriptView Raw
1import { isProduction } from './env';
2
3/* eslint no-console: 0 */
4
5/**
6 * 反对使用某一方法或属性的警告
7 * @param {String} props 过时的属性或方法名
8 * @param {String} instead 替代的属性或方法名
9 * @param {String} component 组件名
10 *
11 * @example
12 * log.deprecated('onBeforeClose', 'beforeClose', 'Dialog');
13 * // Warning: onBeforeClose is deprecated at [ Dialog ], use [ beforeClose ] instead of it.
14 */
15export function deprecated(props, instead, component) {
16 /* istanbul ignore else */
17 if (!isProduction() && typeof console !== 'undefined' && console.error) {
18 return console.error('Warning: [ ' + props + ' ] is deprecated at [ ' + component + ' ], ' + ('use [ ' + instead + ' ] instead of it.'));
19 }
20}
21
22/**
23 * 控制台警告日志
24 * @param {String} msg
25 * @return {Console<Error> | void}
26 */
27export function warning(msg) {
28 /* istanbul ignore else */
29 if (!isProduction() && typeof console !== 'undefined' && console.error) {
30 return console.error('Warning: ' + msg);
31 }
32}
\No newline at end of file