错误:在 rust 中获取源 HTML 文件“index.html”的规范路径时出错

问题描述 投票:0回答:3

我刚刚在 yew(Rust 前端框架)中启动了一个客户端项目。 我刚刚编写了几行代码,但出现以下错误。

错误:“获取源 HTML 文件“index.html”的规范路径时出错。



我的cargo.toml、main.rs和index.html以及错误消息文件如下:

货物.toml
[package]
name = "yew-app"
version = "0.1.0"
edition = "2021"

[dependencies]
yew = "0.19"

main.rs

use yew::prelude::*;

#[function_component(App)]
fn app() -> Html {
    html! {
        <h1> { "Hello World" } </h1>
    }
}

fn main(){
    yew::start_app::<App>();
}

index.html

<!DOCTYPE html>
<html lang="en">
<head></head>
<body></body>
</html>

终端命令和错误消息:

trunk build
Error: error getting canonical path to source HTML file "index.html"

Caused by:
    The system cannot find the file specified. (os error 2) 

index.html 文件位于文件夹的根目录。
我该如何修复这个错误?

rust webassembly yew
3个回答
0
投票
cd ..
cd <back to root folder>
trunk build

0
投票
Rust 中应用程序的 oot 目录是您使用创建的目录的路径

cargo new yew-app or mkdir yew-app cargo init yew-app

在此目录中将存在cargo.toml 文件,您应该从该目录调用“trunk”命令。 并且index.html也应该驻留在这个根目录中。


0
投票
运行你的

中继服务--开放

src文件夹内的命令

© www.soinside.com 2019 - 2024. All rights reserved.