main.js
1.4 KB
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
import Vue from 'vue'
import App from './App.vue'
import Vant from 'vant';
import 'vant/lib/index.css';
import router from './router'
import { Lazyload } from 'vant';
Vue.use(Lazyload);
import store from './store'//引入store
import FastClick from 'fastclick'
FastClick.attach(document.body) // hack the active pseudo-classes failure caused by -webkit-overflow-scrolling touch
Vue.use(Vant);
Vue.config.productionTip = false
//远程加载js的方式
Vue.component('remote-script', {
render: function (createElement) {
var self = this;
return createElement('script', {
attrs: {
type: 'text/javascript',
src: this.src
},
on: {
load: function (event) {
self.$emit('load', event);
},
error: function (event) {
self.$emit('error', event);
},
readystatechange: function (event) {
if (this.readyState == 'complete') {
self.$emit('load', event);
}
}
}
});
},
props: {
src: {
type: String,
required: true
}
}
});
new Vue({
router,
store,
render: h => h(App),
data: {
eventHub: new Vue() //的空vue对象。就可以使用 this.$root.eventHub 获取对象。 / bus接收事件
}
}).$mount('#app')