Alternatively, in your custom_typings folder (if you have that), you can add a new import-png.d.ts
file:
declare module "*.png" {
const value: any;
export default value;
}
So you can import an image using:
import myImg from 'img/myImg.png';
Alternatively, as reported by @mario-petrovic, you sometimes need to use a different export option as below (export = syntax). See here for the differences between the two approaches:
declare module "*.png" {
const value: any;
export = value;
}
In which case you probably need to import the image as:
import * as myImg from 'img/myImg.png';
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…