slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.93k stars 568 forks source link

Parse error: expected a top-level item such as a component, a struct, or a global #3581

Closed LXS2000 closed 11 months ago

LXS2000 commented 11 months ago

my cargo.toml

[dependencies]
slint={version = "1.2.1",features = ["std","backend-winit","renderer-femtovg","compat-1-2"]}

[build-dependencies]
slint-build="1.2.1"

my build.rs fn main(){ slint_build::compile("ui/App.slint").unwrap(); }

my App.slint

import { HorizontalBox, VerticalBox } from "std-widgets.slint";
import { IButton } from "components/IBotton.slint";
import { Home } from "Home.slint";
import { Data,Css,Rule,Env } from "gloabl.slint";
component App inherits Wndow{
   。。。
}

my main.rs slint::include_modules!(); pub fn main() { App::new().unwrap().run().unwrap(); }

when i running main.rs ,i always get error like this

Caused by: process didn't exit successfully: E:\xxx\target\debug\build\hook_ui-bcfd62e356ff13eb\build-script-build (exit code: 101) --- stderr error: Parse error: expected a top-level item such as a component, a struct, or a global --> E:\project_space\rust\hook\hook_ui\ui/App.slint:1:1 | 1 | import { HorizontalBox, VerticalBox } from "std-widgets.slint"; | ^

thread 'main' panicked at 'called Result::unwrap() on an Err value: CompileError(["E:\project_space\rust\hook\hook_ui\ui/App.slint:1: Parse error: expected a top-level item such as a component, a struct, or a global"])', build.rs:2:42 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

i tried other slint version,but it didnt work either

LXS2000 commented 11 months ago

I solved this problem by myself,the reason is due to coding issues