博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
在vue 中使用 less的教程详解
阅读量:7281 次
发布时间:2019-06-30

本文共 1257 字,大约阅读时间需要 4 分钟。

1.安装

npm install --save-dev less less-loader

npm install --save-dev style-loader css-loader

先在index.html页面head标签内插入这段代码

前端精品教程:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<script>
  
(
function
(doc, win) {
   
var
docEl = doc.documentElement,
    
resizeEvt =
'orientationchange'
in
window ?
'orientationchange'
:
'resize'
,
    
recalc =
function
() {
     
var
clientWidth = docEl.clientWidth;
     
if
(!clientWidth)
return
;
     
if
(clientWidth >= 640) {
      
docEl.style.fontSize =
'100px'
;
     
}
else
{
      
docEl.style.fontSize = 100 * (clientWidth / 640) +
'px'
;
     
}
    
};
 
   
if
(!doc.addEventListener)
return
;
   
win.addEventListener(resizeEvt, recalc,
false
);
   
doc.addEventListener(
'DOMContentLoaded'
, recalc,
false
);
  
})(document, window);
 
</script>

在添加 build/webpack.base.conf.js 里面的

module.exports 里的 module 里添加下面这段配置

前端精品教程:

1
2
3
4
5
6
7
8
{
 
test: /\.less$/,
 
use: [
  
"style-loader"
,
  
"css-loader"
,
  
"less-loader"
 
]
}

组建 headers

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<template>
  
<div class=
"box"
> <p>header</p> </div>
</template>
 
<script>
export
default
{
 
name:
"headers"
,
 
data() {
  
return
{};
 
}
};
</script>
 
<style scoped lang=
"less"
>
.box {
 
height: 300/50rem;
 
width: 200/50rem;
 
 
font-size: 16/50 rem;
}
</style>

 

效果展示:  

转载于:https://www.cnblogs.com/zanguixuan/p/9811135.html

你可能感兴趣的文章
Spinner使用二
查看>>
android 隐藏输入法键盘
查看>>
Android jni 中打印logcat日志
查看>>
SSL和keystore生成、导入等配置
查看>>
The Eagles Hotel California Lyrics
查看>>
软件工程——课程评价
查看>>
OpenStack Placement Project
查看>>
微信支付问题
查看>>
购买类目的概率预测
查看>>
Ajax Step By Step2
查看>>
codeforces 701 B. Cells Not Under Attack
查看>>
当同时安装Python2和Python3后,如何兼容并切换使用详解(比如pip使用)
查看>>
Creating a Custom Page Layout in SharePoint 2013
查看>>
mysql foreignkey
查看>>
Django 中的自定义分页标签
查看>>
[转]ASP.NET自定义控件复杂属性声明持久性浅析
查看>>
PAT (Basic Level) Practise (中文)-卡拉兹(Callatz)猜想
查看>>
第八周进度总结
查看>>
axios 注意点
查看>>
刷新ListView刷新时的闪烁问题
查看>>