simulationUI

SimulationUI自定义下拉列表之一概设

由于修改 select 元素自带的默认样式以及 option 选择的默认样式并不能满足某些特定的人员的特定需求,同时也怀着重造轮子的精神,一起来写个能自定义样式的模拟select,因此有了这个小项目,有了想法就开始实施了。

此时,则有SimulationSelect类的内容

var SimulationSelect = function (config) {
    // 此处相当于深拷贝
    this.config = Object.assign({
        data: []
    }, config)
    this.el = document.querySelector(this.config.el)
    this.options = []
    this.options.selectedIndex = 0
    this.value = ''
} 

则有,以下代码

SimulationSelect.prototype = {
    constructor: SimulationSelect,
    init: function () {
        this.render()
        this.bindEvent()
    },
    render: function () {},
    bindEvent: function () {},
    destroy: function () {}
}

模拟下拉列表

总结

以上即为组件重写的基本架构,功能的完善可在此基础上添砖加瓦。此处希望给大家抛砖引玉,下一篇继续完善该组件,更多的是功能性的编写。