rust 我怎样用Dioxus设置顺风css vscode扩展?

rkkpypqq  于 2023-02-12  发布在  Vscode
关注(0)|答案(1)|浏览(253)

我目前正在使用Dioxus( rust )的前端WASM。
我希望设置Tailwind CSS IntelliSense(Tailwind是通过CLI工作的),但我似乎不能让它工作。

// settings.json
 "tailwindCSS.experimental.classRegex": ["class:s*\"([^\"]*)"],
  "tailwindCSS.includeLanguages": {
    "rust": "html"
  }

下面是一个示例组件:

use dioxus::{core::UiEvent, events::MouseData, prelude::*};
use std::cmp::{max, min};

#[derive(PartialEq, Props)]
pub struct NavbarProps<'a> {
    page_state: &'a UseState<i32>,
}

pub fn Navbar<'a>(cx: Scope<'a, NavbarProps<'a>>) -> Element<'a> {
    let go_next = move |_: UiEvent<MouseData>| cx.props.page_state.modify(|val| min(val + 1, 17));
    let go_prev = move |_: UiEvent<MouseData>| cx.props.page_state.modify(|val| max(val - 1, 1));

    cx.render(rsx! (
        div {
            button {
                class: "p-1 bg-red-300 ",
                onclick: go_prev,
                "<",
            }
            button {
                class: "p-1 bg-red-700",
                onclick: go_next,
                ">"
            }
        }
    ))
}

有什么想法吗?

von4xj4u

von4xj4u1#

Dioxus的这种配置对我很有效:

"tailwindCSS.experimental.classRegex": [
   "class: \"(.*)\""
],
"tailwindCSS.includeLanguages": {
    "rust": "html"
},

相关问题