0๐
you can call result of iteration with room.id
not rooms.id
, this might just be a typo in your template
code.
0๐
Iโve worked it out โ I could only access the array by assigning the constant to roomData.rooms
(as opposed to just roomData
). So working code looks like:
<script>
import { ref } from 'vue'
import roomData from '../../data/db.json'
export default {
components: {},
setup(){
const rooms = ref(roomData.rooms)
console.log(rooms.value)
return { rooms }
}
}
</script>
- [Vuejs]-Can't run vue.js projects which i downloaded in visual studio code and getting this: ERR! A complete log of this run can be found in:
- [Vuejs]-How do I connect CustomAuthenticationProvider to frontend?
0๐
to import your json you can do this with SFC in vuejs3
<script setup>
import roomData from '../../data/db.json'
console.log(roomData)
</script>
Source:stackexchange.com