vue中的import {} from '@/api/api'

例:import {queryDepartTreeList, searchByKeywords} from '@/api/api'

首先查看vue.config.js文件,在这个文件里面定义了定义了@的含义

const path = require('path')

function resolve(dir) {
  return path.join(__dirname, dir)
}
module.exports = {
chainWebpack: (config) => {
  config.resolve.alias
    .set('@$', resolve('src'))
    .set('@api', resolve('src/api'))
    .set('@assets', resolve('src/assets'))
    .set('@comp', resolve('src/components'))
    .set('@views', resolve('src/views'))
    .set('@layout', resolve('src/layout'))
    .set('@static', resolve('src/static'))
}
}

 

.set('@api', resolve('src/api')) ,表示 @api 指的是"src/api"路径 

在该文件下我们可以找到以下函数

 


const queryDepartTreeList = (params)=>getAction("",params);
const searchByKeywords   = (params)=>getAction("",params);

 并且有export将该js中的函数向外暴露

export {
  queryDepartTreeList,
  searchByKeywords,
}

 

 表示将该函数引入当前文件
posted @ 2019-11-26 09:50  千彧  阅读(14262)  评论(0编辑  收藏  举报