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
import Vue from 'vue'
import moment from 'moment'
import App from './App'
import uView from "uview-ui";
import vuexStore from "@/store/$u.mixin.js";
import store from '@/store/index'
import {router,RouterMount} from '@/router/index.js' //路径换成自己的
Vue.config.productionTip = false
Vue.mixin(vuexStore)
Vue.use(uView);
App.mpType = 'app'
const app = new Vue({
store,
...App
})
// 引入时间组件 moment
moment.locale('zh-cn');
Vue.prototype.moment = moment
Vue.filter('datefmt',function (input,fmtstring) {//当input为时间戳,需转为Number类型
if(input){
return moment(input).format(fmtstring);
}else{
return "";
}
});
// http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
import httpInterceptor from '@/common/http.interceptor.js'
Vue.use(httpInterceptor, app)
Vue.use(router)
// http接口API抽离,免于写url或者一些固定的参数
import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app)
// 分享
let mpShare = require('@/uview-ui/libs/mixin/mpShare.js')
Vue.mixin(mpShare)
//v1.3.5起 H5端 你应该去除原有的app.$mount();使用路由自带的渲染方式
// #ifdef H5
RouterMount(app,router,'#app')
// #endif
// #ifndef H5
app.$mount(); //为了兼容小程序及app端必须这样写才有效果
// #endif