我正在使用create-react-app和制作一个反应应用程序react-router-dom 4。我的问题是,当我加载默认“/”以外的 URL 时,相对路径会被添加到正在发出的请求中。
例如,如果我进入mysite.com/templatesurl 搜索栏,我的 fetch 请求会fetch("templates/item.json")请求 url:mysite.com/templates/templates/item.json但如果我从主页导航到/templates使用Linkreact-router-dom 中的 组件,则情况并非如此。
有什么方法可以避免在获取请求之前添加相对路径?
fetch reactjs react-router create-react-app react-router-dom
我正在制作自己的地形图,我一直在使用NASA的.hgt文件.
我正在使用加载文件
void MapImage::load_map_file(const char* filename) {
std::ifstream file(filename, std::ios::in | std::ios::binary);
if (!file) {
std::cout << "Error opening file!" << std::endl;
}
std::vector<short> tempHeight(TOTAL_SIZE);
unsigned char buffer[2];
int x, y;
for (int i = 0; i < TOTAL_SIZE; i++) {
if (!file.read(reinterpret_cast<char*>(buffer), sizeof(buffer))) {
std::cout << "Error reading file!" << std::endl;
}
tempHeight[i] = (buffer[0] << 8) | buffer[1];
}
height = tempHeight;
}
Run Code Online (Sandbox Code Playgroud)
然后使用以下命令将它们添加到内存位图:
void MapImage::loadTextureImage() {
img_tex = 0;
glGenTextures(1, &img_tex);
int x, y, w, h;
w …Run Code Online (Sandbox Code Playgroud)