varwebpack=require("webpack");module.exports={entry:{index:__dirname+"/src/index.js"},output:{path:__dirname+"/build",filename:"bundle.js"},module:{loaders:[{test:/.vue$/,loader:'vue-loader'},{ test:/\.(png|jpg)$/, loader:'url-loader?limit=1024&name=images/[hash:8].[name].[ext]' },{test:/\.json$/,loader:'json-loader'}]},resolve:{alias:{'vue':'vue/dist/vue.js'}}}已经安装了json-loaderthis.$http.get("../data/slide.json",{}).then((response)=>{console.log(response)}).catch(function(){})打包的时候为什么build文件夹下,webpack没有给我新建json文件啊?难道还要配置什么吗?
2 回答
拉丁的传说
TA贡献1789条经验 获得超8个赞
你必须引入一个模块的时候,就是import'../demo.json'或require的时候webpack才会识别json进行打包。你现在的写法是发送一个http请求,请求资源类型是json类型。
添加回答
举报
0/150
提交
取消
