json文件: /static/config.json
{
"detectionInterval": 15000
}
/build/webpack.base.conf.js 中添加:
'#': resolve('static')
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'@': resolve('src'),
'#': resolve('static')
}
}
js文件中使用
import JsonConfig from '#/config.json'
methods: {
getDetectionInterval() {
const detectionInterval = JsonConfig.detectionInterval
}
}