Vaadin 无法导入 CSS 文件
Vaadin cannot import CSS file
所以我是 Vaadin 和所有这些东西的新手,我目前正在尝试将 CSS-File 集成到我的站点。但是,当我尝试这样做时,在尝试 运行 gradle-Project:
后出现错误
java.lang.IllegalStateException:
Failed to find the following css files in the `node_modules` or `C:\Users\Sebastian Malburg\Documents\Schule_4\SYT\Wind-2\windpark_REST_JSON\.\frontend` directory tree:
- ./frontend/table_style.css
很明显 CSS-File 的路径是错误的,但我不知道从哪里“开始”路径。在互联网上的某个地方,我读到它从项目的根文件夹(我的 build.gradle-File 所在的位置)开始,但它似乎不起作用。
这是我的 class 使用注释的地方:
package windpark.windengine;
import java.awt.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.dependency.StyleSheet;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.data.provider.ListDataProvider;
import com.vaadin.flow.data.renderer.ComponentRenderer;
import com.vaadin.flow.router.Route;
import windpark.model.WindengineData;
@CssImport("./frontend/table_style.css")
@Route("windengine/tables")
public class GridView extends VerticalLayout {
final Grid<WindengineData> grid;
private WindengineService service;
public GridView() {
...
}
}
这是我的项目结构:
编辑:
我已经试过了 ./table_style
。我认为问题可能出在 Vaadin 在 think 中自动使用的路径:C:\Users\Sebastian Malburg\Documents\Schule_4\SYT\Wind-2\windpark_REST_JSON\.\frontend
。我猜 \.\
无效?我将如何更改此路径?
Use only file name of css, since your css in frontend folder
@CssImport("./table_style.css")
您的 CSS 文件放置在错误的目录中。您在 target/frontend
下有它。它应该放在直接存在于项目目录中的 /frontend
下。
一旦放在那里,你应该使用 @CssImport("./table_style.css")
正如 Shubham 指出的那样。
所以我是 Vaadin 和所有这些东西的新手,我目前正在尝试将 CSS-File 集成到我的站点。但是,当我尝试这样做时,在尝试 运行 gradle-Project:
后出现错误java.lang.IllegalStateException:
Failed to find the following css files in the `node_modules` or `C:\Users\Sebastian Malburg\Documents\Schule_4\SYT\Wind-2\windpark_REST_JSON\.\frontend` directory tree:
- ./frontend/table_style.css
很明显 CSS-File 的路径是错误的,但我不知道从哪里“开始”路径。在互联网上的某个地方,我读到它从项目的根文件夹(我的 build.gradle-File 所在的位置)开始,但它似乎不起作用。
这是我的 class 使用注释的地方:
package windpark.windengine;
import java.awt.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.dependency.StyleSheet;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.data.provider.ListDataProvider;
import com.vaadin.flow.data.renderer.ComponentRenderer;
import com.vaadin.flow.router.Route;
import windpark.model.WindengineData;
@CssImport("./frontend/table_style.css")
@Route("windengine/tables")
public class GridView extends VerticalLayout {
final Grid<WindengineData> grid;
private WindengineService service;
public GridView() {
...
}
}
这是我的项目结构:
编辑:
我已经试过了 ./table_style
。我认为问题可能出在 Vaadin 在 think 中自动使用的路径:C:\Users\Sebastian Malburg\Documents\Schule_4\SYT\Wind-2\windpark_REST_JSON\.\frontend
。我猜 \.\
无效?我将如何更改此路径?
Use only file name of css, since your css in frontend folder
@CssImport("./table_style.css")
您的 CSS 文件放置在错误的目录中。您在 target/frontend
下有它。它应该放在直接存在于项目目录中的 /frontend
下。
一旦放在那里,你应该使用 @CssImport("./table_style.css")
正如 Shubham 指出的那样。