类型编号不能分配给类型字符串

时间:2015-10-27 04:13:35

标签: javascript

我正在制作增量游戏并遇到错误.........键入'数字'不能分配类型'字符串'在所有document.getElement ....

var vegetas = 0;
var gohan = 0;

function vegetaClick(number) {
    vegetas = vegetas + number;
    document.getElementById("Textout").innerHTML = vegetas;
};

function buyGohan() {
    var gohanCost = Math.floor(10 * Math.pow(1.1,gohan));     
    if(vegetas >= gohanCost){                                   
        gohan = gohan + 1;                                   
        vegetas = vegetas - gohanCost;                         
        document.getElementById("gohan").innerHTML = gohan;  
        document.getElementById('vegetas').innerHTML = vegetas;  
        document.getElementById("gohan").style.display= "block";
    };
    var nextCost = Math.floor(10 * Math.pow(1.1,gohan));       
    document.getElementById('gohanCost').innerHTML = nextCost;  
};

1 个答案:

答案 0 :(得分:0)

强制.match("/pattern/i"); 强制转换为字符串值:

nextCost

document.getElementById('gohanCost').innerHTML = "" + nextCost;  
相关问题