Comments (3)
react-imvc
的 css
引用方式是通过 controller
的 preload
配置配合 Style
组件完成的,见文档Style
import React from 'react'
import Controller from 'react-imvc/controller'
import { Style } from 'react-imvc/component' // 加载 Style 组件
export default class extends Controller {
preload = {
main: 'path/to/css' // 配置 css 文件路径
}
View = View
}
// 当组件渲染时,Style 标签会将 preload 里的同名 css 内容,展示为 style 标签。
function View() {
return (
<div>
<Style name="main" />
</div>
)
}
将 antd
的 antd.css
文件拷贝到 src/css/antd.css
,然后配置 preload.antd
为 /css/antd.css
,让 controller 自动取预加载内容,然后通过 <Style name="antd" />
去渲染样式内容。
from react-imvc.
在/src/css目录中增加private_antd.less文件
@import 'antd/dist/antd.less';
增加gulpfile.js文件
`const gulp = require('gulp');
const less = require('gulp-less');
gulp.task('less', function () {
return gulp
.src('./src/**/*.less')
.pipe(less({ javascriptEnabled: true }))
.pipe(gulp.dest('./publish/src'))
.pipe(gulp.dest('./publish/static'))
.pipe(gulp.dest('./src'));
});
gulp.task('watch', function () {
return gulp.watch('./src/**/*.less', gulp.series('less'));
});
在routes中的Layout文件中插入
<link href={${props.publicPath}/css/private_antd.css
} rel="stylesheet" type="text/css">`
package.json中 scripts中增加
"start": "concurrently 'npm:work' 'npm:watch'",
"work": "react-imvc start --config imvc.config.js",
"watch": "gulp watch",
然后就可以愉快的使用less了
from react-imvc.
是的:)
react-imvc 支持通过 preload 方式引入原生 css 文件。编写 less/postcss 可以通过 gulp task 的方式生成原生 css 文件~~
from react-imvc.
Related Issues (18)
- 请问图片怎么引入呢 HOT 2
- alias HOT 1
- 编译的时候比较慢,是不是可以把部分dependencies放到devDependencies HOT 1
- Use <a href="#"> Reload Page HOT 2
- devtools缺省建议换成cheap-module-source-map HOT 6
- 创建的项目控制台有个错误 HOT 2
- build/setup-dev-env.js 中 setupServer 读取的配置文件是client端 HOT 3
- controller/index.js中 能否支持自定义fetch
- component/Input组件的value数据结构不一致
- 2.5.0版本新增的错误处理,无法处理异步的生命周期
- 增加initialstate 保护性复制功能 是否能自定义开启还是关闭
- Controller类中的handler方法模块化 HOT 2
- 使用富文本组件时 关闭服务端渲染也会报 window is not defined at Object.../node_modules/for-editor/dist/index.js (evalmachine.:101:63) HOT 3
- React 18 support plan HOT 2
- 文档需要更新,创建项目时,除了安装 react、react-dom、还要安装 @babel/runtime
- 请问怎么引用less和外部的js文件,具体在哪里配置呢 HOT 1
- align
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-imvc.