我正在制作增量游戏并遇到错误.........键入'数字'不能分配类型'字符串'在所有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;
};
答案 0 :(得分:0)
强制.match("/pattern/i");
强制转换为字符串值:
nextCost
或
document.getElementById('gohanCost').innerHTML = "" + nextCost;