第一次来这里,希望我一切都好。 我对JavaScript还是很陌生,因此很抱歉这很简单。我需要获取说的参数类型是字符串的长度...我很迷失,感谢您的帮助。
def __init__(self, **kwargs):
super(InterfaceManager, self).__init__(**kwargs)
self.first = Button(text="First")
self.first.bind(on_press=self.show_second)
self.second = Image(source="parentaladvisory.jpg")
self.second.bind(on_press=self.show_final)
self.final = Label(text="Hello World")
self.add_widget(self.first)
#I wanted to make the "final" display two of more images.
def show_second(self, button):
self.clear_widgets()
self.add_widget(self.second)
def show_final(self, button):
self.clear_widgets()
self.add_widget(self.final)
class MyApp(App):
def build(self):
return InterfaceManager(orientation='vertical')
if __name__ == '__main__':
MyApp().run()
答案 0 :(得分:0)
只需在函数参数中将“输入”变量更改为“文本”变量。
<button style="position: absolute; top: 0px;" onclick="typeWriter('hello world', '70')">CLICK ME</button>
<p style="padding-top: 50px; text-align: center;" id="loadingText" class="loadingTitle"></p>
<script>
var letters;
var i = 0;
function typeWriter(text, speed) {
console.log(text)
var textLength = text.length;
if (i < textLength) {
document.getElementById("loadingText").innerHTML += text.charAt(i);
i++;
setTimeout(typeWriter, +speed);
if (i == Math.max(textLength)) {
}
}
}
</script>
答案 1 :(得分:0)
您在这里遇到了几个问题:
input
不是text
else {}
语句(Math.max
就是要在2个以上的数字中找到最大值)
var i = 0;
function typeWriter(input, speed) {
if (i < input.length) {
document.getElementById("loadingText").innerHTML += input[i];
i++;
setTimeout(function () { typeWriter(input, speed) }, speed);
} else {
// final stuff
}
}
document.getElementById('button').addEventListener('click', function() {
typeWriter('hello world', 70);
});
<button id="button" style="position: absolute; top: 0px;">CLICK ME</button>
<p style="padding-top: 50px; text-align: center;" id="loadingText" class="loadingTitle"></p>