#
zhou zhou
7 天以前 bccdb8f81c07c8a9cdcd6838173dfd1c73c98d90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import App from './App'
import messages from './locale/index.js'
 
let i18nConfig = {
    locale: uni.getLocale(), // 获取已设置的语言
    messages
}
 
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
 
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
 
import uView from '@/uni_modules/uview-ui'
Vue.use(uView)
 
Vue.mixin({
    methods: {
        $showToast(options) {
            if (this.$refs.uToast) {
                this.$refs.uToast.show(options);
            } else {
                // Fallback if component not found or loaded yet
                uni.$u.toast(typeof options === 'string' ? options : (options.message || options.title));
            }
        }
    }
})
 
const i18n = new VueI18n(i18nConfig)
const app = new Vue({
    ...App,
    i18n
})
 
// 引入请求封装,将app参数传递到配置中
require('./config/request.js')(app)
 
app.$mount()
// #endif
 
// #ifdef VUE3
import {
    createSSRApp
} from 'vue'
import uView from '@/uni_modules/uview-ui'
export function createApp() {
    const app = createSSRApp(App)
    app.use(uView)
    app.mixin({
        methods: {
            $showToast(options) {
                if (this.$refs.uToast) {
                    this.$refs.uToast.show(options);
                } else {
                    uni.$u.toast(typeof options === 'string' ? options : (options.message || options.title));
                }
            }
        }
    })
    return {
        app
    }
}
// #endif