Files
AnHanNET-UniAPP/main.js
xixingwl 98cfbb0b77 注释
2023-02-04 08:50:14 +08:00

34 lines
952 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import App from './App'
import ajax from '@/common/ajax.js' // 路径需根据项目实际情况
import store from './store'
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
// Vue2挂载在 Vue 原型链上,则通过 this.$ajax 调用
Vue.prototype.$ajax = ajax
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import {
createSSRApp
} from 'vue'
export function createApp() {
const app = createSSRApp(App)
app.use(store)
// Vue3 (Options API)挂载在当前应用上app 为 createSSRApp 后的应用),也是通过 this.$ajax 调用
// 我们在写 Vue3 时更推荐用 Composition API即不挂载在实例上
app.config.globalProperties.$ajax = ajax
// 如果你在项目中有用到 nvue 页面,是无法通过 this.$ajax 调用
// 需要将请求方法添加到 uni 对象上,然后通过 uni.$ajax 调用
uni.$ajax = ajax
return {
app
}
}
// #endif