demo.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import 'babel-polyfill';
  2. import Vue from 'vue';
  3. import App from './demo.vue';
  4. import router from './demo-router.js';
  5. import NutUI from './nutui.js';
  6. import Conf from '../config.json';
  7. import demoHeader from './package/demoheader/index.js';
  8. import share from './asset/js/share.min.js';
  9. Vue.prototype.NUTCONF = Conf;
  10. NutUI.install(Vue);
  11. Vue.component('nut-demoheader', demoHeader);
  12. Vue.directive('highlight',function (el) {
  13. hljs.highlightBlock(el)
  14. });
  15. const app = new Vue({
  16. router,
  17. render: h => h(App),
  18. }).$mount('#demo');
  19. let pageLoading = app.$loading({
  20. cover: false,
  21. iconUrl: "data:image/svg+xml,%3Csvg class='icon' viewBox='0 0 1024 1024' xmlns='http://www.w3.org/2000/svg' width='30' height='30'%3E%3Cdefs%3E%3Cstyle/%3E%3C/defs%3E%3Cpath d='M512 0a28.426 28.426 0 0 0-28.447 28.447V256a28.447 28.447 0 1 0 56.894 0V28.447A28.426 28.426 0 0 0 512 0zm0 739.553A28.426 28.426 0 0 0 483.553 768v227.553a28.447 28.447 0 1 0 56.894 0V768A28.426 28.426 0 0 0 512 739.553zM190.198 149.975a28.442 28.442 0 0 0-40.223 40.223l160.89 160.88a28.442 28.442 0 1 0 40.224-40.222zm522.936 522.947a28.442 28.442 0 0 0-40.223 40.222l160.891 160.881a28.442 28.442 0 1 0 40.223-40.223zM284.447 512A28.426 28.426 0 0 0 256 483.553H28.447a28.447 28.447 0 0 0 0 56.894H256A28.426 28.426 0 0 0 284.447 512zm711.106-28.447H768a28.447 28.447 0 1 0 0 56.894h227.553a28.447 28.447 0 0 0 0-56.894zM310.866 672.922l-160.891 160.88a28.442 28.442 0 1 0 40.223 40.223l160.88-160.89a28.442 28.442 0 1 0-40.222-40.224zm382.157-313.498a28.355 28.355 0 0 0 20.111-8.335l160.891-160.891a28.442 28.442 0 1 0-40.223-40.223l-160.88 160.89a28.447 28.447 0 0 0 20.1 48.559z' fill='%23bfbfbf'/%3E%3C/svg%3E",
  22. padding: '0.3',
  23. bgColor: 'rgba(0,0,0,.7)',
  24. iconRotate: true,
  25. text: ''
  26. });
  27. router.beforeEach((to, from, next) => {
  28. pageLoading.show();
  29. next();
  30. })
  31. router.beforeResolve((to, from, next) => {
  32. next();
  33. });
  34. router.afterEach((to, from) => {
  35. pageLoading.hide();
  36. });
  37. var shareOption = {
  38. iconUrl: 'http://nutui.jd.com/asset/img/share.png',
  39. url: location.href,
  40. title: "NutUI - 基于Vue2.0的移动端开源组件库",
  41. desc: '一套拥有电商基因的基于Vue2.0的轻量级移动端开源组件库'
  42. };
  43. try {
  44. /*初始化分享*/
  45. window.share.shareInit(shareOption);
  46. } catch (e) {
  47. console.log(e);
  48. }