A
A
Alexander Ivanov2018-02-03 22:32:09
Vue.js
Alexander Ivanov, 2018-02-03 22:32:09

How to inherit JSON vue objects?

Laravel turns out to have strong plus default support for Vue. I understand with her. Everything is clear only when it came to the practice of webpack swears
so I inherit json

import apiWorkers from '/workers.api'; // адресс url из laravel полный путь тоже не пашет

export default {
    data(){
        return{
            btn_txt: "Искать",
            apiWorkers
        }
    }
}

As I understand it, he could not collect arrays because there is no json file yet, and VUE is started before Laravel is loaded.
This is how he put together:
<script>
import apiWorkers from './workers.json'; //обычный файл в той же папке

export default {
    data(){
        return{
            btn_txt: "Искать",
            apiWorkers
        }
    }
}
</script>

But I can't generate the file every time. How to be in such a situation?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Kitaev, 2018-02-03
@cimonlebedev

I may not understand something, but usually all sorts of "JSON files" are provided by the API that you write on the backend and they definitely do not get into the assembly, but are requested by AJAX.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question