main.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import Vue from 'vue'
  2. import App from '@/App'
  3. import $store from '@/store'
  4. import config from "./config.js"
  5. Vue.prototype.$config = config
  6. import uView from "uview-ui";
  7. Vue.use(uView);
  8. //全局引入iconpark图标
  9. // import { install } from '@icon-park/vue/es/all';
  10. // install(Vue, '');
  11. // Vue.use(VueRouter)
  12. //配置跳转小程序
  13. // Vue.config.ignoredElements = ['wx-open-launch-weapp'];
  14. //配置防止连点的公共方法
  15. import common from './common/util/clicks.js'
  16. Vue.prototype.$noMultipleClicks = common.noMultipleClicks;
  17. // 防连点方法
  18. Vue.directive('throttle', {
  19. inserted(el, binding) {
  20. el.addEventListener('click', () => {
  21. el.style.pointerEvents = 'none'
  22. if (!el.disabled) {
  23. setTimeout(() => {
  24. el.style.pointerEvents = 'auto'
  25. }, binding.value || 2000)
  26. }
  27. })
  28. }
  29. })
  30. Vue.prototype.$store = $store // vuex
  31. Vue.prototype.$offset = function(selector) { // 获取元素宽高位置信息
  32. return new Promise((resolve, reject) => {
  33. uni.createSelectorQuery().in(this).select(selector).boundingClientRect(data => {
  34. console.log(data,'data')
  35. data ? data.x = data.left + data.width / 2 : ''
  36. data ? data.y = data.top + data.height / 2 : ''
  37. data ? resolve(data) : reject('元素不存在')
  38. }).exec()
  39. })
  40. }
  41. import CustomNav from './components/public/custom-nav.vue' //自定义头部导航栏交互组件
  42. Vue.component('custom-nav', CustomNav) //注册自定义头部导航栏
  43. import * as filters from '@/filters'
  44. Object.keys(filters).forEach(e => {
  45. Vue.filter(e, filters[e])
  46. })
  47. App.mpType = 'app'
  48. Vue.config.productionTip = false;
  49. (new Vue({
  50. ...App
  51. })).$mount()