当前位置: 首页 > news >正文

山东省住房和城乡建设厅网站省财政厅经济建设处网站

山东省住房和城乡建设厅网站,省财政厅经济建设处网站,在线 建站单页面网站带后台,中国还有多少人没有打新冠疫苗文章目录 1、css1.1 react和vue css的对比1.2 内联样式1.3 普通的css1.4 css modules1.5 在react中使用less1.6 CSS in JS1.6.1 模板字符串的基本使用1.6.2 styled-components的基本使用1.6.3 接受传参1.6.4 使用变量1.6.5 继承样式 避免代码冗余1.6.6 设置主题色 1.7 React中添…

文章目录

  • 1、css
    • 1.1 react和vue css的对比
    • 1.2 内联样式
    • 1.3 普通的css
    • 1.4 css modules
    • 1.5 在react中使用less
    • 1.6 CSS in JS
      • 1.6.1 模板字符串的基本使用
      • 1.6.2 styled-components的基本使用
      • 1.6.3 接受传参
      • 1.6.4 使用变量
      • 1.6.5 继承样式 避免代码冗余
      • 1.6.6 设置主题色
    • 1.7 React中添加class

1、css

1.1 react和vue css的对比

在这里插入图片描述

1.2 内联样式

在这里插入图片描述

在这里插入图片描述

1.3 普通的css

在这里插入图片描述

  • 缺点:css文件是全局样式 会影响到其他的同名的样式,进行样式的堆叠

1.4 css modules

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

1.5 在react中使用less

  • 1、在根文件中创建 craco.config.js文件夹
    • 安装carco npm i @craco/craco
    • 设置内容
const CracoLessPlugin = require("craco-less");module.exports = {plugins: [{plugin: CracoLessPlugin,options: {lessLoaderOptions: {lessOptions: {modifyVars: { "@primary-color": "#1DA57A" },javascriptEnabled: true}}}}],babel: {plugins: [["@babel/plugin-proposal-decorators", { legacy: true }]]}
};
    • 下载装饰器 npm i @babel/plugin-proposal-decorators -S
  • 2、修改package.json文件
"scripts": {"start": "craco start","build": "craco build","test": "craco test","eject": "react-scripts eject"},

报错可能是版本问题更新一下版本 npm update

在这里插入图片描述
在这里插入图片描述

1.6 CSS in JS

1.6.1 模板字符串的基本使用

// 1.模板字符串的基本使用
const str = `my name is ${name}, age is ${age}`;
console.log(str);// 2.标签模板字符串的使用
function foo(...args) {console.log(args);
}foo(name, age); // (2) ['why', 18]// 这也是一种调用方法
foo``; // [['']]foo`my name is ${name}, age is ${age}`;// 得到的结果变量是默认为空
// [['my name is','','age is',''],'why',18]

在这里插入图片描述

1.6.2 styled-components的基本使用

  • npm install styled-components
    下载vscode插件
    在这里插入图片描述
    在这里插入图片描述

在这里插入图片描述

1.6.3 接受传参

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

1.6.4 使用变量

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

import React, { Component } from "react";
import { AppWrapper, SectionWrapper } from "./style";class App extends Component {constructor() {super();this.state = {size: 30,color: "yellow",};}render() {const { size, color } = this.state;return (<AppWrapper><div className="footer">我是footer</div><SectionWrapper fontSize={size} color={color}><div className="title">我是标题</div><p className="content">我是内容, 哈哈哈</p><button onClick={(e) => this.setState({ color: "skyblue" })}>修改颜色</button></SectionWrapper></AppWrapper>);}
}export default App;
import styled from "styled-components";
import * as vars from "./style/variables";// 1、基本使用
// export const AppWrapper = styled.div``export const AppWrapper = styled.div`/* 使用AppWrapper作为标签 就会继承样式 */.footer {background-color: black;}
`;// 2、将子元素单独抽取到一个样式组件
// 3.可以接受外部传入的props作为参数 也可设置默认值attrsexport const SectionWrapper = styled.div.attrs((props) => ({// 默认用传进来的参数 没有的话就使用20textSize: props.fontSize || 20,textColor: props.color || vars.primaryColor,
}))`/* section不需要写类名 */color: ${(props) => props.textColor};border: 1px solid ${vars.primaryColor};.title {/* 上面使用了新的变量来处理fontSize 所以需要使用textSize */font-size: ${(props) => props.textSize}px;color: red;}.content {&:hover {color: yellow;}}
`;

1.6.5 继承样式 避免代码冗余

在这里插入图片描述
在这里插入图片描述

1.6.6 设置主题色

在这里插入图片描述
在这里插入图片描述

1.7 React中添加class

  • cnpm install classnames
  • 在这里插入图片描述
http://www.yayakq.cn/news/805588/

相关文章:

  • 宣城网站建设jidela电脑培训机构
  • 那个网站建设好招聘网站有哪些
  • 南阳 网站建设惠州网站模板建站
  • 做公司网站需要准备什么科目企业网络营销策划书
  • 网站开发环境ide梵高网站建设
  • 汕头免费模板建站专门做简历的网站软件
  • 网站建设小故事做网站的抬头标语怎么做
  • 磁县网站制作公司长春广告设计公司
  • 2013年四川省泸州市技能竞赛网站建设样稿做加密网站全站加密的最低成本
  • 重庆网站自己推广dede怎么做视频网站
  • 网站平台选择网站如何做提现功能
  • 网站主机提供商网站报价书
  • 全屏网站设计技巧那个网站教我做美食最好
  • 网站怎么连接网精品课程网站设计与实现开题报告
  • 智能建站系统的建站步骤专业网站建设是哪家便宜
  • 青岛建站模板制作wordpress页头登录
  • 网站制作商城wordpress 4.7.3主题
  • 做网站用什么ide男女做床上网站
  • 杭州网站开发工资自然堂网站建设平台分析
  • 扬州网站建设哪个好薇教育网站解决方案
  • 创建微网站午夜资源站
  • 县工商局 网站建设建设公司哪家好
  • 化妆品网站模版免费下载做外贸做几个网站合适
  • 自己建个电影网站可以吗标志设计论文
  • 网站设计实训报告广州网站设计哪里找
  • 做外卖那些网站好家政公司简介模板
  • 公司微信网站建设方案不做百度推广网站关键词被屏蔽
  • 网站名称搜索不到工程建设项目货物招标投标办法
  • 泉州北京网站建设价格手机开网店的免费平台
  • 广州品牌型网站建设大资讯wordpress主题