
Vue学习笔记——vue.config.js(路径别名)以及 .editorconfig(代码风格规定)
发布日期:2021-05-12 21:17:55
浏览次数:22
分类:原创文章
本文共 1793 字,大约阅读时间需要 5 分钟。
在主项目目录下分别创建一个vue.config.js(路径别名)以及 .editorconfig(代码风格规定)。
路径别名作用:
设置好了路径别名后,可在使用这些路径下的内容时,不用使用 **…/**来进行目录回退,
可直接使用别名,即使文件目录发生变化,只要规定的这些别名没有变化,则不需要改变。
路径别名设置举例:
module.exports = { configureWebpack: { resolve: { alias: { 'assets': '@/assets', 'common': '@/common', 'components': '@/components', 'network': '@/network', 'views': '@/views', } } }}
使用方式如下:
①import等方式直接用别名
②在DOM中使用,则在前面需要加上 “~”
(分别在导入img时加上 ~,以及再导入组件时直接用components)
<template> <tab-bar> <tab-bar-item path="/home"> <img slot="item-icon" src="~assets/img/tabbar/home.svg" alt=""> <img slot="item-icon-active" src="~assets/img/tabbar/home_active.svg" alt=""> <div slot="item-text">首页</div> </tab-bar-item> <tab-bar-item path="/category"> <img slot="item-icon" src="~assets/img/tabbar/category.svg" alt=""> <img slot="item-icon-active" src="~assets/img/tabbar/category_active.svg" alt=""> <div slot="item-text">分类</div> </tab-bar-item> <tab-bar-item path="/cart"> <img slot="item-icon" src="~assets/img/tabbar/shopcart.svg" alt=""> <img slot="item-icon-active" src="~assets/img/tabbar/shopcart_active.svg" alt=""> <div slot="item-text">购物车</div> </tab-bar-item> <tab-bar-item path="/profile"> <img slot="item-icon" src="~assets/img/tabbar/profile.svg" alt=""> <img slot="item-icon-active" src="~assets/img/tabbar/profile_active.svg" alt=""> <div slot="item-text">我的</div> </tab-bar-item> </tab-bar></template><script> import TabBar from 'components/common/tabbar/TabBar' import TabBarItem from 'components/common/tabbar/TabBarItem'
代码风格规定举例:
root = true[*]charset = utf-8indent_style = spaceindent_size = 2end_of_line = lfinsert_final_newline = truetrim_trailing_whitespace = true
发表评论
最新留言
留言是一种美德,欢迎回访!
[***.207.175.100]2025年04月06日 18时59分29秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
The wxWindows Library Licence (WXwindows)
2021-05-12
leetcode——第203题——虚拟头结点
2021-05-12
【编程】C语言入门:1到 100 的所有整数中出现多少个数字9
2021-05-12
MySQL----基础及常用命令
2021-05-12
flink启动(二)
2021-05-12
前端开发进阶手册.pdf
2021-05-12
软件架构设计和MESH经验之谈
2021-05-12
关于宝塔面板安装的mysql用Navicat连接出现2003的错误解决
2021-05-12
Windows2016 FTP用户隔离
2021-05-12
js传入参数是中文的时候出现 “******”未定义错误
2021-05-12
吴恩达机器学习课程笔记(英文授课) Lv.1 新手村(回归)
2021-05-12
pair的用法
2021-05-12
SQL基本操作命令
2021-05-12
C# WinForm程序退出的方法
2021-05-12
onFailure unexpected end of stream
2021-05-12
Flex 布局的自适应子项内容过长导致其被撑大问题
2021-05-12
PL/SQL 动态Sql拼接where条件
2021-05-12
Lua-table 一种更少访问的安全取值方式
2021-05-12
虚函数
2021-05-12