赞
踩
在项目根目录创建jsconfig.json文件,将下面代码添加进去
- {
- "compilerOptions": {
- "baseUrl": "./",
- "paths": {
- "@/*": ["src/*"]
- }
- },
- "exclude": ["node_modules", "dist"]
- }
同时在vue.config.js中添加以下代码:
- configureWebpack: {
- // provide the app's title in webpack's name field, so that
- // it can be accessed in index.html to inject the correct title.
- name: name,
- resolve: {
- alias: {
- '@': resolve('src')
- }
- }
- },
即可用@指代src目录。
css中不生效解决办法:
<img :src="require('assets/img/header/search.png')">
背景图:
<button :style="{backgroundImage: 'url(' + require('@/assets/serch_icon.png') + ')'}"></button>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。