专业编程教程与实战项目分享平台

网站首页 > 技术文章 正文

#前端自动化# require.context #前端自动化部署工具

ins518 2024-09-25 22:16:56 技术文章 16 ℃ 0 评论

更多内容可关注博主微信公众号id:study458

/pages/ContentView/component.js 文件

const files = require.context(".", true, /\.jsx$/);
// console.log('files',files.keys())
const components = [];
files.keys().map((item, index) => {
    if (item === "./index.jsx") {
        return false;
    }

    let obj = {}
    const pathArr = item.split("/");
    const path = pathArr
        .slice(1, pathArr.length - 1)
        .join("/")
        .toLowerCase();
    const retPath = `/home/${path}`;


    const component = files(item).default
    obj.component = component
    obj.path = retPath
    components.push(obj)
});

export default components


本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表