Vue中import from@符号指的是什么意思
作者:小志的博客
这篇文章主要介绍了Vue中import from@符号指的是意思,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
vue import from@符号指的是什么意思
1、假设vue文件中引入如下代码
import { auth } from "@/utils/auth";2、@符号表示的含义
- @符号表示一个特定路径名称
- 这个设置引入的是src/utils路径下的auth.js文件
3、lz的vue框架中,@符号可以在build/vue.config.js文件中设置,如下图:lz的@符号表示src路径
具体在哪个文件下的vue配置文件可根据实际情况参考

.vue文件中 import xxx from '@/xxx' 中@含义
@的定义在 vue.config.js中
'use strict'
const path = require('path')
const defaultSettings = require('./src/settings.js')
function resolve(dir) {
return path.join(__dirname, dir)
}
const name = defaultSettings.title || 'vue Element Admin' // page title
// If your port is set to 80,
// use administrator privileges to execute the command line.
// For example, Mac: sudo npm run
const port = 3001 // dev port
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: { // @代表 src/这个路径
'@': resolve('src')
}
}
},由以上的代码可知,@代表 src这个绝对路径
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
