在重温《编码:隐匿在计算机软硬件背后的语言》第12章——二进制加法器时,心血来潮用JS写了一个模拟串行加法器。

测试断言工具TestUtils.js

function assertTrue(actual){
    if(!actual)
        throw "Error actual: "   actual   " is not true."
}

function assertFalse(actual){
    if(actual)
        throw "Error actual: "   actual   " is not false."
}

function assertIntEquals(expected, actual){
    if(typeof expected != "number")
        throw "Error expected: "   expected  " is not a number."

    if(typeof actual != "number")
        throw "Error actual: "   actual  " is not a number."

    if(expected != actual)
        throw "Error expected: "   expected   " and actual: "   actual  " is different."
}

十进制数与二进制数之间转换工具utils.js

function int2LowEightBitArray(num){
    var result = []
    for(var i = 0; i < 8; i  )
        result.push(((num >> i) & 1) == 1)
    return result
}

function lowEightBitArray2Int(array){
    var result = 0
    for(var i = 0; i < 8; i  ){
        if(array[i])
            result  = (1 << i)
    }
    return result
}

function lowNineBitArray2Int(array){
    var result = 0
    for(var i = 0; i < 9; i  ){
        if(array[i])
            result  = (1 << i)
    }
    return result
}

//用补码表示负数
function int2EightBitArray(num){
    if(num < -128 || num > 127){
        throw "Out of boundary(-128, 127)."
    }
    var result = []
    for(var i = 0; i < 8; i  )
        result.push(((num >> i) & 1) == 1)
    return result
}

function eightBitArray2Int(array){
    var result = 0
    for(var i = 0; i < 7; i  ){
        if(array[i])
            result  = (1 << i)
    }
    if(array[i])
        result  = -128
    return result
}

function int2SixteenBitArray(num){
    if(num < -(1 << 15) || num > (1 << 15) - 1){
        throw "Out of boundary({left}, {right})."
            .replace("{left}", -(1 << 15))
            .replace("{right}", (1 << 15) - 1)
    }
    var result = []
    for(var i = 0; i < 16; i  )
        result.push(((num >> i) & 1) == 1)
    return result
}

function sixteentBitArray2Int(array){
    var result = 0
    for(var i = 0; i < 15; i  ){
        if(array[i])
            result  = (1 << i)
    }
    if(array[i])
        result  = -(1 << 15)
    return result
}

加法器模型model.js

class DoubleInGate{
    #id
    #in1
    #in2
    #gateTypeName
    #func
    #out
    #lastOut
    #outReceiver
    #outReceiverInName

    constructor(id, gateTypeName, in1 = false, in2 = false, func){
        this.#id = id
        this.#gateTypeName = gateTypeName
        this.#in1 = in1
        this.#in2 = in2
        this.#func = func
        this.#out = this.#func(this.in1, this.in2)
        // this.#lastOut = this.#out
    }
    
    updateIn1(flag){
        this.#in1 = flag
        this.#updateOut()
    }
    
    updateIn2(flag){
        this.#in2 = flag
        this.#updateOut()
    }
    
    getOut(){
        return this.#out;
    }

    updateBothIn(in1 = false, in2 = false){
        this.#in1 = in1
        this.#in2 = in2
        this.#updateOut()
    }
    
    setOutReceiver(outReceiver, inName){
        this.#outReceiver = outReceiver
        this.#outReceiverInName = inName
    }

    #updateOut(){
        this.#lastOut = this.#out
        this.#out = this.#func(this.#in1, this.#in2)
        if(this.#out != this.#lastOut){
            this.#send(this.#out)
        }
    }

    #send(flag){
        if(this.#outReceiver){
            this.#outReceiver.receive(this.#outReceiverInName, flag)
        }
    }

    receive(inName, flag){
        if(inName == "in1"){
            this.updateIn1(flag)
        }else if(inName == "in2"){
            this.updateIn2(flag)
        }
    }

    toString(){
        return "{gateTypeName} id: {id}, in1: {in1}, in2: {in2}, out:{out}"
            .replace("{gateTypeName}", this.#gateTypeName)
            .replace("{id}", this.#id)
            .replace("{in1}", this.#in1)
            .replace("{in2}", this.#in2)
            .replace("{out}", this.#out)
    }
}

//与门
class AndGate extends DoubleInGate{
    constructor(id, in1 = false, in2 = false){
        super(id, "AndGate", in1, in2, (i1, i2) => i1 && i2)
    }
}

//或门
class OrGate extends DoubleInGate{
    constructor(id, in1 = false, in2 = false){
        super(id, "OrGate", in1, in2, (i1, i2) => i1 || i2)
    }
}

//异或门
class XorGate extends DoubleInGate{
    constructor(id, in1 = false, in2 = false){
        //^在js按位异或, 而在java中不是
        super(id, "XorGate", in1, in2, (i1, i2) => (i1 || i2) && !(i1 && i2)) 
    }
}

class SingleInGate{
    #id
    #in
    #out
    #lastOut
    #func
    #outReceiver
    #outReceiverInName

    constructor(id, in_, func){
        this.#id = id
        this.#in = in_
        this.#func = func
        this.#out = this.#func(this.#in)
        // this.#lastOut = this.#out
    }

    updateIn(flag){
        this.#in = flag
        this.#updateOut()
    }

    getOut(){
        return this.#out
    }

    //注册输出端口接收者,(类观察者模式)
    setOutReceiver(outReceiver, inName){
        this.#outReceiver = outReceiver
        this.#outReceiverInName = inName
    }

    #updateOut(){
        this.#lastOut = this.#out
        this.#out = this.#func(this.#in)
        if(this.#out != this.#lastOut){
            this.#send(this.#out)
        }
    }

    #send(flag){
        if(this.#outReceiver){
            this.#outReceiver.receive(this.#outReceiverInName, flag)
        }    
    }

    receive(inName, flag){
        if(inName == "in"){ //TODO 或许有更灵活的写法
            this.updateIn(flag)
        }
    }
}

class NullGate extends SingleInGate{
    constructor(id, in_= false){
        super(id, in_, a=>a)
    }
}

class NotGate extends SingleInGate{
    constructor(id, in_= false){
        super(id, in_, a=>!a)
    }
}

class Adder{
    #id
    #inA
    #inB
    
    #outS
    #outC
    #lastOutS
    #lastOutC

    #outSReceiver
    #outSReceiverInName
    #outCReceiver
    #outCReceiverInName

    constructor(id, inA=false, inB=false, outS, outC){
        this.#id = id
        this.#inA = inA
        this.#inB = inB
        this.#outS = outS
        this.#outC = outC
    }

    updateInA(flag, func){
        this.#inA = flag
        this.updateOutSAndOutC(func)
    }

    updateInB(flag, func){
        this.#inB = flag
        this.updateOutSAndOutC(func)
    }

    updateBothIn(inA, inB, func){
        this.#inA = inA
        this.#inB = inB
        this.updateOutSAndOutC(func)
    }

    getOutS(){
        return this.#outS
    }

    getOutC(){
        return this.#outC
    }

    #updateOutS(flag){
        this.#lastOutS = this.#outS
        this.#outS = flag
        if(this.#outS != this.#lastOutS){
            this.#sendOutS(this.#outS)
        }
    }
    
    #updateOutC(flag){
        this.#lastOutC = this.#outC
        this.#outC = flag
        if(this.#outC != this.#lastOutC){
            this.#sendOutC(this.#outC)
        }
    }
    
    updateOutSAndOutC(func){
        if(func){
            var results = func()
            this.#updateOutS(results[0])
            this.#updateOutC(results[1])
        }
    }

    setOutSReceiver(outSReceiver, inName){
        this.#outSReceiver = outSReceiver
        this.#outSReceiverInName = inName
    }

    setOutCReceiver(outCReceiver, inName){
        this.#outCReceiver = outCReceiver
        this.#outCReceiverInName = inName
    }

    receive(inName, flag){
        if(inName == "inA"){
            this.updateInA(flag)
        }else if(inName == "inB"){
            this.updateInB(flag)
        }
    }

    #sendOutS(flag){
        if(this.#outSReceiver){
            this.#outSReceiver.receive(this.#outSReceiverInName, flag)
        }
    }

    #sendOutC(flag){
        if(this.#outCReceiver){
            this.#outCReceiver.receive(this.#outCReceiverInName, flag)
        }
    }
}

class HalfAdder extends Adder{
    #xorGate
    #andGate

    constructor(id, inA=false, inB=false){
        var xorGate = new XorGate(undefined, inA, inB);
        var andGate = new AndGate(undefined, inA, inB);
        super(id, inA, inB, xorGate.getOut(), andGate.getOut())
        this.#xorGate = xorGate
        this.#andGate = andGate 
    }

    #returnOutArray(){
        return [this.#xorGate.getOut(), this.#andGate.getOut()]
    }

    updateInA(flag){
        super.updateInA(flag, ()=>{
            this.#xorGate.updateIn1(flag)
            this.#andGate.updateIn1(flag)
            return this.#returnOutArray()
        })
    }

    updateInB(flag){
        super.updateInB(flag, ()=>{
            this.#xorGate.updateIn2(flag)
            this.#andGate.updateIn2(flag)
            return this.#returnOutArray()
        })
    }

    updateBothIn(inA, inB){
        super.updateBothIn(inA, inB, ()=>{
            this.#xorGate.updateBothIn(inA, inB)
            this.#andGate.updateBothIn(inA, inB)
            return this.#returnOutArray()
        })
    }

}

class FullAdder extends Adder{
    #inC
    #halfAdder1
    #halfAdder2
    #orGate

    constructor(id, inA = false, inB = false, inC = false){
        var halfAdder1 = new HalfAdder(undefined, inA, inB)
        var halfAdder2 = new HalfAdder(undefined, inC, halfAdder1.getOutS())
        var orGate = new OrGate(undefined, halfAdder1.getOutC(), halfAdder2.getOutC())
        super(id, inA, inB, halfAdder2.getOutS(), orGate.getOut())
        this.#inC = inC
        this.#halfAdder1 = halfAdder1
        this.#halfAdder2 = halfAdder2
        this.#orGate = orGate

        this.#halfAdder1.setOutSReceiver(halfAdder2, "inB")
        this.#halfAdder1.setOutCReceiver(orGate, "in1")
        this.#halfAdder2.setOutCReceiver(orGate, "in2")
    }

    #returnOutArray(){
        return [this.#halfAdder2.getOutS(), this.#orGate.getOut()]
    }

    updateInA(flag){
        super.updateInA(flag, ()=>{
            this.#halfAdder1.updateInA(flag)
            return this.#returnOutArray()
        })
    }

    updateInB(flag){
        super.updateInB(flag, ()=>{
            this.#halfAdder1.updateInB(flag)
            return this.#returnOutArray()
        })
    }

    updateInC(flag){
        this.#inC = flag
        this.#halfAdder2.updateInA(flag)
        this.updateOutSAndOutC(()=>{
            return this.#returnOutArray()
        })
    }

    updateBothIn(inA, inB){
        super.updateBothIn(inA, inB, ()=>{
            this.#halfAdder1.updateBothIn(inA, inB)
            return this.#returnOutArray()
        })
    }

    updateThreeIn(inA, inB, inC){
        super.updateBothIn(inA, inB)
        this.#inC = inC

        this.#halfAdder1.updateBothIn(inA, inB)
        this.#halfAdder2.updateBothIn(inC, this.#halfAdder1.getOutS())
        this.#orGate.updateBothIn(this.#halfAdder1.getOutC(), this.#halfAdder2.getOutC())

        this.updateOutSAndOutC(()=>{
            return this.#returnOutArray()
        })
    }

    receive(inName, flag){
        super.receive(inName, flag)
        if(inName == "inC"){
            this.updateInC(flag)
        }
    }
}

class EightBitBinaryAdder{
    #inC
    #outC
    #lastOutC

    #inA
    #inB
    #outS

    #fullAdders
    #fullAdderNum

    #outCReceiver
    #outCReceiverInName

    #outCInOutSFlag

    constructor(outCInOutSFlag = false){
        this.#outCInOutSFlag = outCInOutSFlag
        this.#inC = false
        this.#fullAdderNum = 8
        this.#fullAdders = []

        this.#inA = []
        this.#inB = []

        for(var i = 0; i < this.#fullAdderNum; i  ){
            this.#inA.push(false)
            this.#inB.push(false)
        }

        //新键8个全加器
        for(var i = 0; i < this.#fullAdderNum; i  ){
            this.#fullAdders.push(new FullAdder("f"   i))
            if(i != 0){
                this.#fullAdders[i - 1].setOutCReceiver(this.#fullAdders[i], "inC")
            }
        }

        this.updateOut()
    }

    updateBothIn(arrayA, arrayB){
        // this.#inC = inC
        this.#inA = arrayA
        this.#inB = arrayB

        for(var i = 0; i < this.#fullAdderNum; i  ){
            if(i == 0){
                this.#fullAdders[i].updateInC(this.#inC)
            }
            this.#fullAdders[i].updateBothIn(arrayA[i], arrayB[i])
        }
        this.updateOut()
    }

    //输出默认值
    updateOut(){
        this.#outS = []

        for(var i = 0; i < this.#fullAdderNum; i  ){
            this.#outS.push(this.#fullAdders[i].getOutS())
            if(i == this.#fullAdderNum - 1){
                this.#lastOutC = this.#outC
                this.#outC = this.#fullAdders[i].getOutC()

                if(this.#lastOutC != this.#outC)
                    this.#sendOutC(this.#outC)

                if(this.#outCInOutSFlag)
                    this.#outS.push(this.#outC)

            }
        }
    }

    updateInC(flag){
        this.#inC = flag
        this.updateBothIn(this.#inA, this.#inB, flag)
    }

    receive(inName, flag){
        if(inName == "inC"){
            this.updateInC(flag)
        }
    }

    #sendOutC(flag){
        if(this.#outCReceiver){
            this.#outCReceiver.receive(this.#outCReceiverInName, flag)
        }
    }

    setOutCReceiver(outCReceiver, inName){
        this.#outCReceiver = outCReceiver
        this.#outCReceiverInName = inName
    }

    getOut(){
        return this.#outS
    }
}

class SixteenBitBinaryAdder{
    #inC
    #outC
    #lastOutC

    #inA
    #inB
    #outS

    #eightBitBinaryAdder1
    #eightBitBinaryAdder2

    #bitNum = 16

    #outCReceiver
    #outCReceiverInName

    #outCInOutSFlag

    constructor(outCInOutSFlag){
        this.#outCInOutSFlag = outCInOutSFlag
        this.#inC = false
        this.#eightBitBinaryAdder1 = new EightBitBinaryAdder()
        this.#eightBitBinaryAdder2 = new EightBitBinaryAdder()

        this.#inA = []
        this.#inB = []

        for(var i = 0; i < this.#bitNum; i  ){
            this.#inA.push(false)
            this.#inB.push(false)
        }

        this.#eightBitBinaryAdder1.setOutCReceiver(this.#eightBitBinaryAdder2, "inC")

        this.updateOut()
    }

    updateBothIn(arrayA, arrayB){
        this.#inA = arrayA
        this.#inB = arrayB
        this.#eightBitBinaryAdder1.updateBothIn(arrayA.slice(0, 8), arrayB.slice(0, 8))
        this.#eightBitBinaryAdder2.updateBothIn(arrayA.slice(8), arrayB.slice(8))
        this.updateOut()
    }

    updateOut(){
        this.#outS = this.#eightBitBinaryAdder1.getOut().concat(this.#eightBitBinaryAdder2.getOut())
        //发送send(OutC)
    }
    getOut(){
        return this.#outS
    }

    //TODO
    // updateInC(flag){
    //     this.#inC = flag

    //     this.updateBothIn(this.#inA, this.#inB, flag)
    // }

    // receive(inName, flag){
    //     if(inName == "inC"){
    //         this.updateInC(flag)
    //     }
    // }

    #sendOutC(flag){
        if(this.#outCReceiver){
            this.#outCReceiver.receive(this.#outCReceiverInName, flag)
        }
    }

    setOutCReceiver(outCReceiver, inName){
        this.#outCReceiver = outCReceiver
        this.#outCReceiverInName = inName
    }

}

运行验证代码testModel.js
验证通过判据:后台没有打印输出异常。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Test</title>
    <script src="../js/test/TestUtils.js"></script>
    <script src="../js/model.js"></script>
    <script src="../js/utils.js"></script>
</head>
<body>

    <script>
        var g1 = new NullGate("g1")
        var g2 = new NullGate("g2")
        var g3 = new NullGate("g3")
        var g4 = new NullGate("g4")
        var g5 = new NullGate("g5")
        var g6 = new NullGate("g6")

        g1.setOutReceiver(g2, "in")
        g2.setOutReceiver(g3, "in")
        g3.setOutReceiver(g4, "in")
        g4.setOutReceiver(g5, "in")
        g5.setOutReceiver(g6, "in")

        g1.updateIn(true)
        assertTrue(g6.getOut())
    </script>

    <script>
        //与门
        var andGate = new AndGate("a01")
        assertFalse(andGate.getOut())

        andGate.updateIn1(true)
        assertFalse(andGate.getOut())

        andGate.updateIn2(true)
        assertTrue(andGate.getOut())

        //或门
        var orGate = new OrGate("o01")
        assertFalse(orGate.getOut())

        orGate.updateIn1(true)
        assertTrue(orGate.getOut())

        orGate.updateIn2(true)
        assertTrue(orGate.getOut())

        //异或门
        var xorGate = new XorGate("x01")
        assertFalse(xorGate.getOut())

        xorGate.updateIn1(true)
        assertTrue(xorGate.getOut())

        xorGate.updateIn2(true)
        assertFalse(xorGate.getOut())

        xorGate.updateBothIn(false, true)
        assertTrue(xorGate.getOut())

    </script>
    <script>
        //半加器
        var ha = new HalfAdder("h01")
        assertFalse(ha.getOutS())
        assertFalse(ha.getOutC())
        
        ha.updateInB(true)
        assertTrue(ha.getOutS())
        assertFalse(ha.getOutC())

        ha.updateInA(true)
        assertFalse(ha.getOutS())
        assertTrue(ha.getOutC())

        ha.updateBothIn(true, false)
        assertTrue(ha.getOutS())
        assertFalse(ha.getOutC())
    </script>

    <script>
        //全加器
        var fa = new FullAdder("fa01")
        assertFalse(fa.getOutC())
        assertFalse(fa.getOutS())

        function test(inA, inB, inC, expectedS, expectedC){
            fa.updateThreeIn(inA, inB, inC)
            if(expectedS)
                assertTrue(fa.getOutS())
            else
                assertFalse(fa.getOutS())

            if(expectedC)
                assertTrue(fa.getOutC())
            else
                assertFalse(fa.getOutC())
        }

        test(false, false, false, false, false)
        test(false, true, false, true, false)
        test(true, false, false, true, false)
        test(true, true, false, false, true)
        test(false, false, true, true, false)
        test(false, true, true, false, true)
        test(true, false, true, false, true)
        test(true, true, true, true, true)
        
    </script>

    <script>
        for(var i = 0 ; i < 256; i  ){
            assertIntEquals(i, lowEightBitArray2Int(int2LowEightBitArray(i)))
        }
    </script>
    <script>
        var ebba = new EightBitBinaryAdder(true)

        for(var i = 0; i < 256; i  ){
            for(var j = 0; j < 256; j  ){i
                ebba.updateBothIn(int2LowEightBitArray(i), int2LowEightBitArray(j))
                assertIntEquals(i   j, lowNineBitArray2Int(ebba.getOut()))
            }
        }

    </script>
    <script>
        for(var i = -128; i <= 127; i  ){
            assertIntEquals(i, eightBitArray2Int(int2EightBitArray(i)))
        }
    </script>
    <script>
        var ebba = new EightBitBinaryAdder()

        for(var i = -64; i < 64; i  ){
            for(var j = -64; j < 64; j  ){
                ebba.updateBothIn(int2EightBitArray(i), int2EightBitArray(j))
                assertIntEquals(i   j, eightBitArray2Int(ebba.getOut()))
            }
        }
    </script>
    <script>
        for(var i = -(1<<15); i <= (1<<15) - 1; i  ){
            assertIntEquals(i, sixteentBitArray2Int(int2SixteenBitArray(i)))
        }
    </script>

    <script>
        var sbba = new SixteenBitBinaryAdder()

        sbba.updateBothIn(int2SixteenBitArray(1156), int2SixteenBitArray(9999))
        assertIntEquals(9999   1156, sixteentBitArray2Int(sbba.getOut()))

        //‭16384‬ * ‭16384‬ = 268435456 如果这样算会十分耗时
        // for(var i = -(1<<14); i < (1<<14); i  ){
        //     for(var j = -(1<<14); j < (1<<14); j  ){
        //         sbba.updateBothIn(int2SixteenBitArray(i), int2SixteenBitArray(j))
        //         assertIntEquals(i   j, sixteentBitArray2Int(sbba.getOut()))
        //     }
        // }
        for(var i = -100; i < 100; i  ){
            for(var j = -100; j < 100; j  ){
                sbba.updateBothIn(int2SixteenBitArray(i), int2SixteenBitArray(j))
                assertIntEquals(i   j, sixteentBitArray2Int(sbba.getOut()))
            }
        }
    </script>
</body>
</html>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持Devmax。

JS模拟实现串行加法器的更多相关文章

  1. html5 拖拽及用 js 实现拖拽功能的示例代码

    这篇文章主要介绍了html5 拖拽及用 js 实现拖拽,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  2. amaze ui 的使用详细教程

    这篇文章主要介绍了amaze ui 的使用详细教程,本文通过多种方法给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

  3. swift皮筋弹动发射飞机ios源码

    这是一个款采用swift实现的皮筋弹动发射飞机游戏源码,游戏源码比较详细,大家可以研究学习一下吧。

  4. Swift与Js通过WebView交互

    开发环境:Swfit2.3XCode8.2基础概念jscontext,jscontext是代表JS的执行环境,通过-evaluateScript:方法就可以执行一JS代码JSValue,JSValue封装了JS与ObjC中的对应的类型,以及调用JS的API等JSExport,JSExport是一个协议,遵守此协议,就可以定义我们自己的协议,在协议中声明的API都会在JS中暴露出来,才能调用Swif

  5. JSCore swift

    如果双方相互引用,会造成循环引用,而导致内存泄露。以上是Jscore的基本使用,比较简单

  6. Swift WKWebView的js调用swift

    最近项目需求,需要用到JavaScriptCore和WebKit,但是网上的资源有限,而且比较杂,都是一个博客复制另外一个博客,都没有去实际敲代码验证,下面给大家分享一下我的学习过程。

  7. Swift WKWebView的swift调用js

    不多说,直接上代码:在html里面要添加的的代码,显示swift传过去的参数:这样就实现了swift给js传参数和调用!

  8. 在 Swift 專案中使用 Javascript:編寫一個將 Markdown 轉為 HTML 的編輯器

    你有強烈的好奇心,希望在你的iOS專案中使用JavaScript。jscontext中的所有值都是JSValue對象,JSValue類用於表示任意類型的JavaScript值。因此,我們既需要寫Swift代碼也要寫JavaScript代碼。此外,我們還會在JavaScript中按照這個類的定義來創建一個對象并對其屬性進行賦值。從Swift中呼叫JavaScript就如介紹中所言,JavaScriptCore中最主要的角色就是jscontext類。一個jscontext對象是位於JavaScript環境和本

  9. swift - WKWebView JS 交互

    本文介绍WKWebView怎么与js交互,至于怎么用WKWebView这里就不介绍了HTML代码APP调JS代码结果JS给APP传参数首先注册你需要监听的js方法名2.继承WKScriptMessageHandler并重写userContentController方法,在该方法里接收JS传来的参数3.结果

  10. swift 开发UIWebView跟JS的交互

    前言作为小白的我,才开始入门IOS,选择了swift来进行入门学习,学习做着公司一个简单的小小项目,该项目需要进行跟H5进行交互,然后我就开始研究了UIWebView的使用,其实基本原理跟Android的一样,因为我是Android开发的,所以就顺水推舟了。))//这里设置你需要加载的地址}overridefuncdidReceiveMemoryWarning(){super.didReceiveMemoryWarning()//disposeofanyresourcesthatcanberecreate

随机推荐

  1. js中‘!.’是什么意思

  2. Vue如何指定不编译的文件夹和favicon.ico

    这篇文章主要介绍了Vue如何指定不编译的文件夹和favicon.ico,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教

  3. 基于JavaScript编写一个图片转PDF转换器

    本文为大家介绍了一个简单的 JavaScript 项目,可以将图片转换为 PDF 文件。你可以从本地选择任何一张图片,只需点击一下即可将其转换为 PDF 文件,感兴趣的可以动手尝试一下

  4. jquery点赞功能实现代码 点个赞吧!

    点赞功能很多地方都会出现,如何实现爱心点赞功能,这篇文章主要为大家详细介绍了jquery点赞功能实现代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

  5. AngularJs上传前预览图片的实例代码

    使用AngularJs进行开发,在项目中,经常会遇到上传图片后,需在一旁预览图片内容,怎么实现这样的功能呢?今天小编给大家分享AugularJs上传前预览图片的实现代码,需要的朋友参考下吧

  6. JavaScript面向对象编程入门教程

    这篇文章主要介绍了JavaScript面向对象编程的相关概念,例如类、对象、属性、方法等面向对象的术语,并以实例讲解各种术语的使用,非常好的一篇面向对象入门教程,其它语言也可以参考哦

  7. jQuery中的通配符选择器使用总结

    通配符在控制input标签时相当好用,这里简单进行了jQuery中的通配符选择器使用总结,需要的朋友可以参考下

  8. javascript 动态调整图片尺寸实现代码

    在自己的网站上更新文章时一个比较常见的问题是:文章插图太宽,使整个网页都变形了。如果对每个插图都先进行缩放再插入的话,太麻烦了。

  9. jquery ajaxfileupload异步上传插件

    这篇文章主要为大家详细介绍了jquery ajaxfileupload异步上传插件,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

  10. React学习之受控组件与数据共享实例分析

    这篇文章主要介绍了React学习之受控组件与数据共享,结合实例形式分析了React受控组件与组件间数据共享相关原理与使用技巧,需要的朋友可以参考下

返回
顶部