SASS type-of 函数

本文介绍了一种SASS语言中用于检测变量类型的函数type-of。通过示例演示了如何使用此函数来判断不同的数据类型,包括number、string、bool、color、list、map和null等。

今儿写个type-of,算是备忘录吧。

1.number
type-of(0)                    // number
type-of(1px)                  // number
2.string
type-of(a)                    // string
type-of("a")                  // string
3.bool
type-of(true)                 // bool
type-of(0<1)                  // bool
4.color
type-of(rgba(1,2,3,.3))       // color
type-of(rgb(1,2,3))           // color
type-of(#fff)                 // color
type-of(red)                  // color
5.list(sass.list=js.array)
// 需要加括号
type-of((1px,2px,3px))        // list
type-of((1px 2px 3px rgba(0,0,0,.3))) // list
6.map(sass.map=js.json)
type-of((a:1px,b:2px))        // map
7.null
type-of(null)                 // null
注:检测格式,要用字符串
@if type-of(null) == "null" { ... }

 

转载于:https://www.cnblogs.com/ccforeverd/p/4036886.html

error in ./src/views/modules/config/add-or-update.vue?vue&type=style&index=0&lang=scss& Module build failed (from ./node_modules/sass-loader/dist/cjs.js): Error: Cannot find module 'node-sass' Require stack: - E:\bishezuihzongban\daima\admin\node_modules\sass-loader\dist\getDefaultSassImplementation.js - E:\bishezuihzongban\daima\admin\node_modules\sass-loader\dist\getSassImplementation.js - E:\bishezuihzongban\daima\admin\node_modules\sass-loader\dist\index.js - E:\bishezuihzongban\daima\admin\node_modules\sass-loader\dist\cjs.js - E:\bishezuihzongban\daima\admin\node_modules\loader-runner\lib\loadLoader.js - E:\bishezuihzongban\daima\admin\node_modules\loader-runner\lib\LoaderRunner.js - E:\bishezuihzongban\daima\admin\node_modules\webpack\lib\NormalModule.js - E:\bishezuihzongban\daima\admin\node_modules\webpack\lib\NormalModuleFactory.js - E:\bishezuihzongban\daima\admin\node_modules\webpack\lib\Compiler.js - E:\bishezuihzongban\daima\admin\node_modules\webpack\lib\webpack.js - E:\bishezuihzongban\daima\admin\node_modules\@vue\cli-service\lib\commands\serve.js - E:\bishezuihzongban\daima\admin\node_modules\@vue\cli-service\lib\Service.js - E:\bishezuihzongban\daima\admin\node_modules\@vue\cli-service\bin\vue-cli-service.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:931:15) at Function.Module._load (internal/modules/cjs/loader.js:774:27) at Module.require (internal/modules/cjs/loader.js:1003:19) at require (internal/modules/cjs/helpers.js:107:18) at getDefaultSassImplementation (E:\bishezuihzongban\daima\admin\node_modules\sass-loader\dist\getDefaultSassImplementation.js:24:10) at getSassImplementation (E:\bishezuihzongban\daima\admin\node_modules\sass-loader\dist\getSassImplementation.js:19:72) at Object.loader (E:\bishezuihzongban\daima\admin\node_modules\sass-loader\dist\index.js:40:61) @ ./node_modules/vue-style-loader??ref--8-oneOf-1-0!./node_modules/css-loader/dist/cjs.js??ref--8-oneOf-1-1!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/ postcss-loader/src??ref--8-oneOf-1-2!./node_modules/sass-loader/dist/cjs.js??ref--8-oneOf-1-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/modules/config/add-or-update.vue?vue&type=style&index=0&lang=scss& 4:14-480 14:3-18:5 15:22-488 @ ./src/views/modules/config/add-or-update.vue?vue&type=style&index=0&lang=scss& @ ./src/views/modules/config/add-or-update.vue @ ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/modules/config/list.vue?vue&type=script&lang=js& @ ./src/views/modules/config/list.vue?vue&type=script&lang=js& @ ./src/views/modules/config/list.vue @ ./src/router/router-static.js @ ./src/main.js @ multi (webpack)-dev-server/client?http://172.20.10.6:8081/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
最新发布
06-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值