我有这样一个包,结构如下
index.js
import apiList from './interface'
const install = Vue => {
if (install.installed)
return;
install.installed = true
Object.defineProperties(Vue.prototype, {
api: {
get() { return apiList }
}
})
}
export default install
当在我这样引入包能正常运行
import api from '@/assets/js/http/index'
但是这样就不行
import api from '@/assets/js/http'
不是说 webpack 引入包名,会自动找 index.js 或 package.json的main字段吗?
但是我这里直接引入包名'@/assets/js/http'
无效是什么问题?
我也遇上这个问题了 怎么解决的请问