require.context 基本用法

简介: `require.context`函数接受三个参数 - directory {String} -读取文件的路径 - useSubdirectories {Boolean} -是否遍历文件的子目录 - regExp {RegExp} -匹配文件的正则 ``` 语法: require.

require.context函数接受三个参数

  • directory {String} -读取文件的路径
  • useSubdirectories {Boolean} -是否遍历文件的子目录
  • regExp {RegExp} -匹配文件的正则
语法: require.context(directory, useSubdirectories = false, regExp = /^.//);
例子 require.context('./test', false, /.test.js$/);
相关文章
|
17天前
|
JavaScript 前端开发
JS require 与 import 的区别
JS require 与 import 的区别
14 1
|
4月前
|
JavaScript 前端开发
JS中 require 与 import 的区别
JS中 require 与 import 的区别
|
1月前
vue3配置路由报错Catch all routes (“*“) must now be defined using a param with a custom regexp.
vue3配置路由报错Catch all routes (“*“) must now be defined using a param with a custom regexp.
43 0
|
8月前
react-Native init初始化项目报错”TypeError: cli.init is not a function“
react-Native init初始化项目报错”TypeError: cli.init is not a function“
523 1
|
15天前
|
JavaScript
call、apply、bind的使用场景区分(js的问题)
call、apply、bind的使用场景区分(js的问题)
|
2月前
|
Dart JavaScript 安全
|
4月前
【Webpack】TypeError: Cannot read property ‘tap‘ of undefined at HtmlWebpackPlugin.
【Webpack】TypeError: Cannot read property ‘tap‘ of undefined at HtmlWebpackPlugin.
|
6月前
|
JavaScript Cloud Native Go
Error: Cannot find module ‘webpack/bin/config-yargs‘ at Function.Module._resolveFilename (intern
Error: Cannot find module ‘webpack/bin/config-yargs‘ at Function.Module._resolveFilename (intern
29 0
|
7月前
|
JavaScript
js文件中的require以及import 等语句中的{ }的作用
js文件中的require以及import 等语句中的{ }的作用
|
C语言
函数 require
函数 require
78 0