JavaScript入门 npm包管理工具/css预处理器Day33

npm包管理工具


统一下载第三方包工具

为什么需要包管理工具

项目开发时一定会用到第三方包
   轮播效果        swiper
   网络编程        axios    
   cookie本地存储  js.cookie
   加密            sha256

   到官网下载第三方包

npm包管理工具用法 

nodejs环境一起安装
>npm -v

下载
>npm install 库  
    本地安装  当前目录node_modules文件夹下   
 简写: npm i 库                 
>npm install 库  -g
     全局安装
 
卸载
   npm uninstall  库
   npm uninstall  库  -g
更新
   npm update 库 

nrm工具 镜像管理工具

>npm i nrm -g
>nrm list
>nrm test
>nrm use taobal  

其它包管理工具介绍

cnpm 
  >npm i cnpm -g
  >cnpm i 库
yarn
  >npm i yarn -g
  >yarn add 库
pnpm

npm安装依赖 - 生产环境和开发环境

npm i 库 -D
    -D参数表示安装依赖是开发环境
npm i 库 -S
    -S参数表示安装依赖是生产环境

npm i -g 库 -D 
npm i -g 库 -S 

css预处理器


什么是css预处理器

css扩展语言,用编程的方式书写css样式
三款
   less
   sass
      sass
      scss 最新版本
   stylus

css预处理器编译

1. 定义一个scss后缀结尾文件

    index.css    
       div{
           color:red;
       }
    
    index.scss
       div{
           color:red;
       }
    完全兼容css

2. index.scss 浏览器不能运行scss 

浏览器只能识别 html , css , javascript 

 index.scss -编译->  index.css
     变量
     嵌套

   sass库
   >npm i -g sass -D  
         pageckage.json区分 
   >sass index.scss index.css 
   >sass --watch index.scss:index.css
   >sass --watch scss:css

css预处理器插件

 easy sass

 sass事例

    <div>
        <h2>css预处理器</h2>
        <p>less</p>
        <p>sass</p>
        <p>stylus</p>
    </div>
    <button class="primary-btn">主要按钮</button>
    <button class="success-btn">成功按钮</button>
/*index.scss*/
@import './variable.scss';
@import './mixins.scss';
/*按钮父类*/
.btn {
    @include btnMixin(200px, 40px, skyblue);
}
.primary-btn {
    @extend .btn;
    background-color: #409eff;
    color: white;
}
.success-btn {
    @extend .btn;
    background-color: #67c23a;
    color: white;
    &:hover {
        background-color: #74d145;
        cursor: pointer;
    }
}
div {
    width: 200px;
    h2,
    p {
        font-size: 20px;
    }
    h2 {
        font-weight: 400;
        @include btnMixin(300px, 40px, pink);
        &:hover {
            background-color: skyblue;
            cursor: pointer;
        }
    }
    p {
        color: $color;
        &:first-of-type {
            color: blue;
            @include btnMixin(200px, 30px, skyblue);
        }
    }
}
/*mixins.scss*/
@mixin btnMixin($w, $h, $bgcolor) {
    width: $w;
    height: $h;
    line-height: $h;
    text-align: center;
    background-color: $bgcolor;
    border-radius: 5px;
    border: none;
    outline: none;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值