uniapp-ZHSQ/src/main.js

88 lines
1.6 KiB
JavaScript

import App from './App'
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
App.mpType = 'app'
Vue.config.productionTip = false
import uView from 'uni_modules/uview-ui';
Vue.use(uView);
// 全局分享 mixin - 所有页面默认开启分享到微信好友和朋友圈
Vue.mixin({
onShareAppMessage() {
return {
title: '汇商生活家',
path: '/pages/index/index'
}
},
onShareTimeline() {
return {
title: '汇商生活家',
query: ''
}
}
})
// 导入工具函数
import { processImageUrl } from './utils/index.js'
// 添加全局方法 - Vue 2
Vue.prototype.$processImage = (url) => {
return processImageUrl(url)
}
// 添加全局过滤器 - Vue 2
Vue.filter('processImage', function(url) {
return processImageUrl(url)
})
const app = new Vue({
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import { createApp } from 'vue'
import App from './App.vue'
import uView from 'uni_modules/uview-ui';
const app = createApp(App)
// 安装 uView
app.use(uView)
// 全局分享 mixin - 所有页面默认开启分享到微信好友和朋友圈
app.mixin({
onShareAppMessage() {
return {
title: '汇商生活家',
path: '/pages/index/index'
}
},
onShareTimeline() {
return {
title: '汇商生活家',
query: ''
}
}
})
// 导入工具函数
import { processImageUrl } from './utils/index.js'
// 添加全局方法 - Vue 3
app.config.globalProperties.$processImage = (url) => {
return processImageUrl(url)
}
// 挂载多个全局方法
app.config.globalProperties.$toast = $toast
app.config.globalProperties.$modal = $modal
app.mount('#app')
// #endif
uni.$u.config.unit = 'rpx'