I need to make my Javascript file see the Vue and Axios files

Asked

Viewed 126 times

1

I recently created an Laravel project that is using Vuejs and Axios, and then sent it to the Heroku server, but something strange happened, the page is with the very strange view is giving error in the first line of my app.js file is where you find all the methods I am using

As you can see the error is in the first line of Vue;

inserir a descrição da imagem aqui

This is my app.js file

import Vue from 'vue'
import axios from 'axios'

new Vue({
            el: '#crud',
            created: function() {
                    this.getRegistros();
            },
            data: {
                    registros: [],
                    newDesc: '',
                    newPreco: '',
                    newQtdQuartos: '',
                    newTipo: '',
                    newFinalidade: '',
                    newLogradouroEndereco: '',
                    newBairroEndereco: '',
                    preencherRegistro: {
                        'id': '',
                        'descricao': '',
                        'preco': '',
                        'qtdQuartos': '',
                         tipos: ''  ,// acho que meu problema está aqui******
                        'finalidade': '',// acho que meu problema está aqui******
                        'logradouroEndereco': '',
                        'bairroEndereco': ''
                    },
                    errors: []
            },

            methods: {
                    getRegistros: function() {
                        var urlRegistro = 'imovels';
                        axios.get(urlRegistro).then(response => {
                                this.registros = response.data
                        });
                    },
                    editarRegistro: function(registro) {
                        /*  alert(registro.tipos); */

                             this.preencherRegistro.id = registro.id;
                             this.preencherRegistro.descricao = registro.descricao;
                             this.preencherRegistro.preco = registro.preco;
                             this.preencherRegistro.qtdQuartos = registro.qtdQuartos;
                             this.preencherRegistro.tipos = registro.tipos;
                             this.preencherRegistro.finalidade = registro.finalidade;
                             this.preencherRegistro.logradouroEndereco = registro.logradouroEndereco;
                             this.preencherRegistro.bairroEndereco = registro.bairroEndereco;
                             console.log(this.preencherRegistro.tipos);
                             $('#edit').modal('show');
                    },
                    updateRegistro: function(id) {
                            var url = 'imovels/' + id;
                            axios.put(url, this.preencherRegistro).then(response => {
                                    this.getRegistros();
                                    this.preencherRegistro = {  'id': '',
                                    'descricao': '',
                                    'preco': '',
                                    'qtdQuartos': '',
                                     tipos: ''  ,
                                    'finalidade': '',
                                    'logradouroEndereco': '',
                                    'bairroEndereco': ''  };
                                    this.errors   = [];
                                    $('#edit').modal('hide');
                                    toastr.success('Tarea actualizada con éxito');
                                            }).catch(error => {
                                                this.errors = 'Corrija para poder editar con éxito'
                                            });
                    },
                     createRegistro: function() {
                         var url = 'imovels';
                         axios.post(url, {
                            descricao: this.newDesc,
                            preco: this.newPreco,
                            qtdQuartos: this.newQtdQuartos,
                            tipos: this.newTipo,
                            finalidade: this.newFinalidade,
                            logradouroEndereco:  this.newLogradouroEndereco,
                          bairroEndereco:    this.newBairroEndereco
                         }).then(response => {
                             this.getRegistros();
                             this.newDesc = '';
                             this.newPreco = '';
                             this.newQtdQuartos = '';
                             this.newTipo = '';
                             this.newFinalidade = '';
                             this.newLogradouroEndereco = '';
                             this.newBairroEndereco = '';
                             this.errors = [];
                             $('#create').modal('hide');// efetuar a execução
                            toastr.success('Novo imóvel criado com sucesso!');
                         }).catch(error => {
                                this.errors = error.response.data
                         });
                     },
                    deletarRegistro: function(registro) {
                             var url = 'imovels/' + registro.id;
                             axios.delete(url).then(response => {
                                 this.getRegistros();
                                 toastr.success('Registro excluído com sucesso');
                             });
                    }
            }
        });

I believe you’re wrong are this import s

import Vue from 'vue'
import axios from 'axios'

I have to put in the right paths, see where are my files see and Xios

inserir a descrição da imagem aqui

I believe you’re not so hard to help me, I just don’t because I have little experience with programming.

The briefcase public is in the project root, inside the public folder has the folder lib and inside the lib folder has the files see and Xios.

  • The problem is possibly in the configuration of webpack, your project is in a URL directly or inside a folder? is like this (www.url.com) or (www.url.com/projeto) ?

1 answer

1


import Axios from 'Xios' is correct, you did npm install Xios, are you using it via npm? I believe this may be the error.

  • that’s not the problem.

  • sorry I solved yes.

  • Would you take a look at this please? https://answall.com/questions/251520/comort-project_laravel-visiar-arquivo-axios

Browser other questions tagged

You are not signed in. Login or sign up in order to post.