VUE.JS 通过 webpack-simple 中的 axios 从 url 接收一个 json 文件
VUE.JS Recieve a json file from url via axios in webpack-simple
我是 vue.js 的新手,我尝试从 url 接收列表。
这里有一些问题:
1. 我无法在 main.js 中定义 axios,因此我可以在 index.html 中使用它(此解决方案对我不起作用 )
2.当我使用console.log(response)时,响应为空,因此请求还没有完成
我已经安装了 axios 并且 vue 扔了 vue-cli
main.js
import Vue from 'vue'
import App from './App.vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
Vue.use(VueAxios, axios);
new Vue({
el: '#app',
render: h => h(App)
})
index.html
<template>
<div id="app">{{ info }}</div>
</template>
<script>
export default {
name: "app",
data() {
return {
info: null
};
},
mounted() {
Vue.axios
.get("https://dog.ceo/api/breeds/list/all"
)
.then(response => (this.info = response));
console.log(response);
}
};
所以我只想接收一个列表并以某种方式连接 axios
解决方案是用
this.axios
解决方案是使用
this.axios
我是 vue.js 的新手,我尝试从 url 接收列表。
这里有一些问题:
1. 我无法在 main.js 中定义 axios,因此我可以在 index.html 中使用它(此解决方案对我不起作用
2.当我使用console.log(response)时,响应为空,因此请求还没有完成
我已经安装了 axios 并且 vue 扔了 vue-cli
main.js
import Vue from 'vue'
import App from './App.vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
Vue.use(VueAxios, axios);
new Vue({
el: '#app',
render: h => h(App)
})
index.html
<template>
<div id="app">{{ info }}</div>
</template>
<script>
export default {
name: "app",
data() {
return {
info: null
};
},
mounted() {
Vue.axios
.get("https://dog.ceo/api/breeds/list/all"
)
.then(response => (this.info = response));
console.log(response);
}
};
所以我只想接收一个列表并以某种方式连接 axios
解决方案是用
this.axios
解决方案是使用
this.axios