zguolee / unocss-preset-uni Goto Github PK
View Code? Open in Web Editor NEWThe UniApp preset for UnoCSS
Home Page: https://www.npmjs.com/package/unocss-preset-uni
The UniApp preset for UnoCSS
Home Page: https://www.npmjs.com/package/unocss-preset-uni
Type 'Preset<Theme>' is not assignable to type 'Preset<{}> | Preset<{}>[]'.
Type 'Preset<Theme>' is not assignable to type 'Preset<{}>'.
Types of property 'rules' are incompatible.
Type 'Rule<Theme>[] | undefined' is not assignable to type 'Rule<{}>[] | undefined'.
Type 'Rule<Theme>[]' is not assignable to type 'Rule<{}>[]'.
Type 'Rule<Theme>' is not assignable to type 'Rule<{}>'.
Type '[RegExp, DynamicMatcher<Theme>]' is not assignable to type 'Rule<{}>'.
Type '[RegExp, DynamicMatcher<Theme>]' is not assignable to type '[string, CSSObject | CSSEntries]'.
Type at position 0 in source is not compatible with type at position 0 in target.
Type 'RegExp' is not assignable to type 'string'.
import { resolve } from 'path'
import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import AutoImport from 'unplugin-auto-import/vite'
import Unocss from 'unocss/vite'
import { presetIcons } from 'unocss'
import { presetUni } from 'unocss-preset-uni'
import { UnoCSSToUni } from 'unocss-preset-uni/vite'
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@': resolve('./src'),
},
},
plugins: [
uni(),
// https://github.com/antfu/unplugin-auto-import
AutoImport({
// global imports to register
imports: [
'vue',
'uni-app',
'pinia',
],
dts: 'src/auto-imports.d.ts',
}),
// https://github.com/unocss/unocss
Unocss({
presets: [
presetUni(),
presetIcons(),
],
}),
// https://github.com/zguolee/unocss-preset-uni
// Make sure it's behind Unocss()
UnoCSSToUni(),
],
})
// uno.config.js
import { defineConfig, presetAttributify, presetIcons } from 'unocss';
import presetRemToPx from '@unocss/preset-rem-to-px';
import transformerCompileClass from '@unocss/transformer-compile-class';
import transformerDirective from '@unocss/transformer-directives';
import transformerVariantGroup from '@unocss/transformer-variant-group';
import { presetUni } from 'unocss-preset-uni';
export default defineConfig({
presets: [
presetUni(),
presetAttributify(),
presetIcons({
cdn: 'https://esm.sh/'
}),
presetRemToPx()
],
transformers: [transformerCompileClass(), transformerDirective(), transformerVariantGroup()]
});
<!-- index.vue -->
<template>
<view class=":uno: text-red">Hello</view>
</template>
配合transformerCompileClass 失效, 审查元素发现class已经合并,但是无对应样式
当我的项目中用到了hover-class属性,编译无法通过
17:14:24 [vite] [plugin:vite:vue] Error parsing JavaScript expression: Unexpected token, expected ":" (1:84)
at ../node_modules/@dcloudio/uni-ui/lib/uni-list-item/uni-list-item.vue:7:0
<view :class="{ 'uni-list-item--disabled': disabled }"
:hover-class="(!clickable && !link) || disabled || showSwitch ? '' : 'uni-list-item--hover'"
^
class="uni-list-item" @click="onClick">
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.