我在main.js里面写了如下代码:
Vue.prototype.$handleOrgQuery = function (property) {
let org = sessionStorage.getItem("userOrgs");
if (org) {
console.log('--- org ---', org)
}
}
我在main.js里面写了如下代码:
Vue.prototype.$handleOrgQuery = function (property) {
let org = sessionStorage.getItem("userOrgs");
if (org) {
console.log('--- org ---', org)
}
}
import axios from 'axios'
Vue.prototype.$axios = axios
使用this.$axios.xxx
Vue.prototype
Replaced byconfig.globalProperties
import axios from 'axios';
const app = Vue.createApp(App);
app.config.globalProperties.$axios = axios;
使用this.$axios.xxx
Provide
import axios from 'axios';
const app = Vue.createApp(App);
app.provide('$axios', axios);
Inject
Composition API:
const { inject } = Vue;
...
setup() {
const $axios = inject('$axios');
// $axios.get(...)
}
Options API:
inject: ['$axios'],
9 回答1.7k 阅读✓ 已解决
6 回答1k 阅读
3 回答1.4k 阅读✓ 已解决
4 回答985 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
3 回答887 阅读
3 回答1.3k 阅读✓ 已解决
写错了项目,尴尬