1👍
✅
import
is for static files but require
could work for you
const MY_JSON = require('./2018-05-at-' + date + '.json')
-1👍
I think you have to require json file after this.date
was defined.
<template>
<div>
<h1>loading..</h1>
<span>{{ json }}</span>
</div>
</template>
<script>
export default {
name: 'App',
data() {
return {
date: '2018-05-18',
json: null,
}
},
mounted() {
this.json = require('../test-' + this.date + '.json')
},
}
</script>
Source:stackexchange.com