Javascript Can';t在Vue项目中打开本地.geojson文件

Javascript Can';t在Vue项目中打开本地.geojson文件,javascript,vue.js,webpack,geojson,vue-cli,Javascript,Vue.js,Webpack,Geojson,Vue Cli,我正在尝试在VueJS项目中加载static.geojson文件。Simple.json文件正在工作,但是.geojson文件给了我以下错误: Uncaught Error: Module parse failed: Unexpected token (1:7) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.

我正在尝试在VueJS项目中加载static.geojson文件。Simple.json文件正在工作,但是.geojson文件给了我以下错误:

Uncaught Error: Module parse failed: Unexpected token (1:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> {"type": "FeatureCollection", "features": []}
    at eval (address.geojson:1)
    at Object../src/venue/amenity.geojson (app.js:1418)
    at __webpack_require__ (app.js:854)
    at fn (app.js:151)
    at eval (cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/Prodmap.vue?vue&type=script&lang=js&:13)
等等。。 当然,我可以将所有文件切换到.json,但这只能是一种临时解决方法

import Address from '@/venue/address.json'; // works
import Address from '@/venue/address.geojson'; // gives me the error

Vue CLI以本机方式加载JSON,但我不确定如何为其他扩展配置JSON。还有一个选择:

安装json加载程序:

在项目根目录中的vue.config.js中配置json加载程序(如有必要,请创建文件):


Vue CLI以本机方式加载JSON,但我不确定如何为其他扩展配置JSON。还有一个选择:

安装json加载程序:

在项目根目录中的vue.config.js中配置json加载程序(如有必要,请创建文件):


是的,这就是诀窍。谢谢你是的,这很好。谢谢你
npm install json-loader
module.exports = {
  configureWebpack: {
    module: {
      rules: [
        {
          test: /\.geojson$/,
          loader: 'json-loader'
        }
      ]
    }
  }
}