vue引入全局less实现全局变量的控制

vue引入全局less

  • 1.设置全局样式变量的好处:
  • 2.以less为例(sass等同原理)
      • 1.vue-cli2搭建的项目(1)
      • 2.vue-cli2搭建的项目(2)
      • 3.vue-cli3、vue-cli4
  • 3.vue-cli2和vue-cli3的区别
  • 4.vue-cli3和vue-cli4的区别
  • 5.vue-cli3配置项目的三种办法
    • 1.根目录下创建vue.config.js
    • 2.运行 vue ui,然后打开浏览器进行可视化配置
    • 3.直接在依赖中找到并修改
  • 6.分清vue版本和vue-cli版本

1.设置全局样式变量的好处:

  • 方便页面样式、风格尽量统一,便于多人合作开发
  • 方便统一管理
  • 减少重复工作

2.以less为例(sass等同原理)

安装 sass-resources-loader 依赖:

cnpm install sass-resources-loader --save-dev

1.vue-cli2搭建的项目(1)

找到build文件夹下面的utils.js
exports.cssLoaders = function (options) {}中加入:
path.resolve(__dirname, ‘…/src/assets/styles/common.less’) //具体自己的路径
return{} 中修改:
less: generateLoaders(‘less’) 改为 less: lessResourceLoader()

2.vue-cli2搭建的项目(2)

同样找到其中的return的内容,less: generateLoaders(‘less’)改为:
less: generateLoaders(‘less’).concat({
loader: ‘sass-resources-loader’,
options: {
resources: path.resolve(__dirname, ‘…/src/assets/styles/common.less’)
}
})

3.vue-cli3、vue-cli4

搭建的项目需要自己在根目录下创建vue.config.js,直接写需要修改的配置即可:

module.exports = {
// 加载less加载器,路径:./public/css/common.less
chainWebpack: config => {
const oneOfsMap = config.module.rule(‘less’).oneOfs.store
oneOfsMap.forEach(item => {
item
.use(‘sass-resources-loader’)
.loader(‘sass-resources-loader’)
.options({
// Provide path to the file with resources
resources: ‘./public/css/common.less’,
// Or array of paths
// resources: [’./path/to/vars.scss’, ‘./path/to/mixins.scss’]
})
.end()
})
}
}

3.vue-cli2和vue-cli3的区别

  • vue-cli3是基于webpack4打造,vue-cli2是基于webpack3
  • vue-cli3的设计原则是“0配置”,移除(隐藏)配置文件build和config等目录
  • vue-cli3提供了vue ui 命令,提供了可视化配置
  • vue-cli3移除了static文件夹,新增了public文件夹,并且将index.html移动到public中
  • 2.0启动npm run dev,3.0启动npm run serve

4.vue-cli3和vue-cli4的区别

vue-cli3和vue-cli4的区别

5.vue-cli3配置项目的三种办法

1.根目录下创建vue.config.js

module.exports = {}

2.运行 vue ui,然后打开浏览器进行可视化配置

3.直接在依赖中找到并修改

node_modules@vue\cli-service\webpack.config.js
node_modules@vue\cli-service\lib\Service.js

6.分清vue版本和vue-cli版本

1.cmd中 vue -V 查看的是vue-cli的版本(2、3、4),vue-cli2、vue-cli3可以创建vue2项目;vue-cli4可以创建vue2、vue3项目。
2.查看vue版本需要在package包中查看,或者在vue所在目录进行cmd,输入 npm list vue 查看

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/278647.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

如何在eclipse中对项目进行重新编译

有时由于eclipse异常关闭,当我们重启Eclipse,在启动项目时,会报错,说:ClassNotFound类似的错误,引起这种问题的原因可能是由于,Eclipse异常关闭引起的。 解决:在一个项目中&#xff…

SQL 查询数据库中包含指定字符串的相关表和相关记录

declare str varchar(100)set str我要找的 --要搜索的字符串declare s varchar(8000)declare tb cursor local forselect if exists(select 1 from [b.name] where [a.name] like %str%)print [b.name].[a.name]from syscolumns a join sysobjects b on a.idb.idwhere b.xtype…

如何在Gmail的图片中插入超链接

Adding hyperlinks is an efficient way of getting your reader to the intended web page. Though it’s no secret that you can add hyperlinks to text, Gmail also lets you add hyperlinks to images in the body of the email. Here’s how to make it happen. 添加超链…

内联元素居中

父元素&#xff1a; height:100px; line-height:100px; // 与高相同 text-align:center; 子元素: display:inline; vertical-align: middle; 适用图片、文字 <div><div class"wrapper"><span>我是文字</span></div><div class&qu…

防止html标签转义

function htmlDecode ( str ) {var ele document.createElement(span);ele.innerHTML str;return ele.textContent;} 例如body下边所有的p标签都防止转义&#xff1a; $.each($("body").find(p),function(){this.innerHTML htmlDecode(this.innerHTML);}); 转载于…

新垣结衣自拍照_如何阻止自拍照出现在iPhone的自拍照专辑中

新垣结衣自拍照Khamosh PathakKhamosh PathakThe Photos app on your iPhone automatically populates all photos from the front-facing camera in the Selfies album. But what if you don’t want a photo to appear there? Here are a couple of solutions. iPhone上的“…

前端个人笔记

前端个人笔记1.vue项目安装依赖/插件时忘记--save&#xff0c;再次install出问题并且没有报错。2.margin移动元素不显示背景色3.新知识&#xff1a;media 条件样式4.入坑&#xff1a;row和col不能分离&#xff0c;span24不能不写5.聚焦实现滚动到指定元素1.vue项目安装依赖/插件…

kernel中对文件的读写【学习笔记】【原创】

/*1. 头文件 */ #include <linux/init.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/kernel.h> #include <linux/list.h> #include <linux/fs.h> #include <linux/uaccess.h>MODULE_PARM_DESC(iva…

ssm项目快速搭建(注解)-依赖

父层jar包版本控制&#xff0c;管理配置 <!-- 集中定义依赖版本号 --> <properties> <junit.version>4.12</junit.version> <spring.version>4.2.4.RELEASE</spring.version> <pagehelper.version>4.0.0<…

如何设置自定义任务栏图标_如何为任何应用程序自定义Windows 7任务栏图标

如何设置自定义任务栏图标Would you like to change out the icons on your taskbar with a beautiful set of icons that all go together? Here’s how you can change out the random candy-colored icons for a stylish icon set of your choice. 您是否要用一组漂亮的图…

给谷歌浏览器安装vue调试工具:vue-devtools

安装vue-devtools一、拉取项目二、install、build三、添加扩展四、使用举例一、拉取项目 vue-devtools&#xff1a;git地址&#xff08;master分支&#xff09; 非master分支在build的时候会报错。 二、install、build 1、打开cmd进入项目目录&#xff0c;可以选择npm/cnpm/…

如何找到Windows 7或8家庭组密码?

So you’re about to setup your new Windows 7 PC into your Homegroup when you realized that you have no idea what the password is. How do you find it? It’s actually pretty simple, if you know where to look. 因此&#xff0c;当您意识到自己不知道密码是什么时…

vue3.0、cli4项目引入element plus

element团队为新版的 vue-cli4 准备了相应的 Element Plus 插件 安装依赖 npm install element-plus --savemain.js全局引入&#xff0c;样式文件需要单独引入 import { createApp } from vue import ElementPlus from element-plus; import element-plus/lib/theme-chalk/in…

MySQL索引背后的数据结构及算法原理

title: MySQL索引背后的数据结构及算法原理 date: 2018-07-25 19:50:16 tags: mysql categories: mysql --- 本文转载自http://blog.codinglabs.org/articles/theory-of-mysql-index.html 摘要 本文以MySQL为研究对象&#xff0c;讨论与数据库索引相关的一些话题。特别需要说明…

[SDOI2015]约数个数和

Sol 首先有个结论\(\sum_{i1}^{m}\sum_{j1}^{n}d(i*j)\sum_{i1}^{m}\sum_{j1}^{n}\sum_{x|i}\sum_{y|i}[gcd(x,y)1]\) 证明&#xff1a;可以看po姐的博客 接着这个式子推\[ 原式\sum_{x1}^{n}\sum_{y1}^{m}([gcd(x, y)1] * \sum_{x|i}\sum_{y|i} 1)\\ \sum_{x1}^{n}\sum_{y1}^{…

使用mcBackup备份Windows 7 Media Center设置

If you’re a HTPC enthusiast and use Windows 7 Media Center, you probably have a lot of scheduled recordings and channel lineups you’d like to backup. Here we take a look at a simple tool that will allow you to do it easily. 如果您是HTPC爱好者并且使用Wind…

【CF961G】Partitions(第二类斯特林数)

【CF961G】Partitions&#xff08;第二类斯特林数&#xff09; 题面 CodeForces洛谷 题解 考虑每个数的贡献&#xff0c;显然每个数前面贡献的系数都是一样的。 枚举当前数所在的集合大小&#xff0c;所以前面的系数\(p\)就是&#xff1a;\[\begin{aligned} p&\sum_{i1}^n{…

js绑定事件和阻止事件

js事件一、绑定事件1、html绑定2、el属性绑定3、el函数绑定4、事件捕获与冒泡5、js常见事件称名二、阻止事件1、event.stopPropagation()2、return false3、event.preventDefault();4、兼容写法一、绑定事件 1、html绑定 <div onclick"alert(click!)">click&…

linux中service的问题

1.描述问题 2.解决方案 systemctl stop firewalld systemctl mask firewalldThen, install the iptables-services package: yum install iptables-servicesEnable the service at boot-time: systemctl enable iptablesManaging the service systemctl [stop|start|restart] i…

火狐可以打开谷歌打不开_如何设置Firefox以使用Google Apps打开所有内容

火狐可以打开谷歌打不开Google offers a pretty comprehensive set of online applications which many of you probably take advantage of. Here is how to easily configure Firefox to use Google’s online offerings for email, RSS, PDF and office documents as your d…