文章问题导向
nest如何获取静态资源(images,css,js)?
nest如何使用模板引擎?
如果你都有了答案,可以忽略本文章,或去nest学习导图寻找更多答案
如何获取静态资源?
第一步:安装平台依赖
yarn add @nestjs/platform-express
第二步:在main.ts引入配置使用
import {
NestFactory } from '@nestjs/core';
import {
AppModule } from './app.module';
//引入
import {
NestExpressApplication } from '@nestjs/platform-express'
async function bootstrap() {
//使用
const app = await NestFactory.create<NestExpressApplication>(AppModule);
//使用方式一
app.useStaticAssets('public')