我刚刚在 yew(Rust 前端框架)中启动了一个客户端项目。
我刚刚编写了几行代码,但出现以下错误。
错误:“获取源 HTML 文件“index.html”的规范路径时出错。
[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 文件位于文件夹的根目录。
我该如何修复这个错误?
cd ..
cd <back to root folder>
trunk build
cargo new yew-app
or
mkdir yew-app
cargo init yew-app
在此目录中将存在cargo.toml 文件,您应该从该目录调用“trunk”命令。 并且index.html也应该驻留在这个根目录中。
中继服务--开放src文件夹内的命令