In my @vue/cli 4.0.5 app in any *.vue file I have to import axios, if I need to use it on this page, like:
(在我的@ vue / cli 4.0.5应用程序的任何* .vue文件中,如果我需要在此页面上使用它,则必须导入axios,例如:)
<script>
import {bus} from '../../../src/main'
import appMixin from '@/appMixin'
import axios from 'axios'
...
But I expected axios to be accessible in *.vue file of my app.
(但是我希望可以在我的应用程序的* .vue文件中访问axios。)
In src/main.js I have defined : (在src / main.js中,我定义了:)
import router from './router'
import store from './store'
import axios from 'axios'
...
Vue.use(axios)
moment.tz.setDefault(settingsTimeZone)
export const bus = new Vue()
axios.defaults.crossDomain = true
Vue.config.productionTip = false
Vue.prototype.$http = axios
I have this question as priorly I worked in laravel 5 / vuejs 2.6 app I have axios was accessible in all *.vue files of my app without any definition... Why so and if I have to write
(我有这个问题,因为我之前在laravel 5 / vuejs 2.6应用程序中工作过,我的axios可以在应用程序的所有* .vue文件中访问,而没有任何定义...为什么这样,如果我必须写)
import axios from 'axios'
in any file where I need axios ?
(在我需要axios的任何文件中?)
Thanks!
(谢谢!)
ask by Petro Gromovo translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…