Skip to content

umi到底怎么使用unocss #11034

Closed Answered by xiaohuoni
YangJianFei asked this question in Q&A
Apr 25, 2023 · 5 comments · 7 replies
Discussion options

You must be logged in to vote

感觉文档里面写的很清楚耶 https://umijs.org/docs/guides/styling#%E4%BD%BF%E7%94%A8-unocss

因为 max 就是 umi。有个 demo 的 https://github.com/umijs/umi/tree/master/examples/with-unocss
如果直接看 demo 不是很理解的话,可以通过以下步骤接入。

安装

pnpm i @unocss/cli unocss

配置

config/config.ts 或者 .umirc.ts 中

  plugins: [require.resolve('@umijs/plugins/dist/unocss')],
  unocss: {
    watch: ['pages/**/*.tsx'],
  },
  routes:[

...
    {
      path: "/unocss",
      component: "unocss",
      layout: false,
      name: "unocss",
    },
...
]

验证

新建页面 pages/unocss.tsx

import React from 'react';

export default function HomePage() {
  return (
    <div className="w-full flex flex-row justify-center pb-16">
      <div className="container">

Replies: 5 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@daly-dai
Comment options

@xiaohuoni
Comment options

@sherry007
Comment options

@xiaohuoni
Comment options

@sherry007
Comment options

Answer selected by xiaohuoni
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants