home.page.js 2.25 KB
import Vue from 'vue';

import app from 'example/home.vue';
import tpl from 'example/hello.hbs';
import tip from 'common/tip';

var vm = new Vue({
    el: '#app',
    components: {
        app: app
    }
});

console.log(vm);

/* eslint-disable */
// 私有包测试
import $ from 'jquery';
import qs from 'yoho-qs';
console.log(qs);

import parse from 'yoho-qs/parse'; // 提供解析函数
console.log(parse('q=w&e=r')); // { q: 'w', e: 'r' }

import cookie from 'yoho-cookie';

console.log(cookie.all());

// ES6 test
var test = {
    data() {
        return {
            message: 'test',
            message2: 'test2'
        };
    }
};

// Handlebars/HBS 模版例子
$('#hbs-placeholder').html(tpl({
    text: 'Handlerbars'
}));

/* --------------tip demo---------*/
var tipBtn = document.querySelector('#show-tip');
tipBtn.addEventListener('click', function(){
    tip('中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中')
});


import Overlay from 'common/overlay';
import Modal from 'common/modal';
import customModal from 'example/custom-modal.hbs';
import loading from 'common/loading';

var overlay = new Overlay();

$('#modal-overlay').click(()=> {
    overlay.show();
});

$('#modal-alert').click(()=> {
    Modal.alert('自毁系统已经开启,请马上撤离!', '警告');
});

$('#modal-confirm').click(()=> {
    Modal.confirm('是否开启自毁系统?', '', function() {
        this.hide();
        alert('BOOM!');
    });
});

// 自定义模态
$('#modal-custom').click(()=> {
    const modal = new Modal({
        title: '自定义模态对话框',
        text: '你可以自定义哦!',
        template: customModal,
        buttons: [
            {
                text: '香蕉',
                handler: function() {
                    this.hide();
                    alert('香蕉');
                }
            },
            {
                text: '苹果',
                handler: function() {
                    this.hide();
                    alert('苹果');
                }
            }
        ]
    });
    modal.show();
});


$('#loading').click(()=> {
    loading.show();

    setTimeout(()=> {
        loading.hide();
    }, 3000)
});

/* eslint-enable */