我是新来的。所有在线示例都无法帮助我调试。我想念什么?这个想法是用户输入他们想要转换为密码的内容,然后js函数为他们加密。 js本身运行良好。尝试使函数Crypt()与html一起使用时,断开连接会发生。
override func updateConstraints() {
/// Check if views already have constraints
if !viewsHaveConstraints {
viewsHaveConstraints = true
/*
Here I set the hugging and compression priority for the 3 views in the UIStackView
*/
let margins = safeAreaLayoutGuide
/* Set vstackView constraints */
/// vStackView width anchor equal to width of margin less constant
vStackView.widthAnchor.constraint(equalTo: margins.widthAnchor, constant: -16.0).isActive = true
/// vStackView leading anchor constraint
vStackView.leadingAnchor.constraint(equalTo: margins.leadingAnchor, constant: 8.0).isActive = true
/// vStackView trailing anchor constraint
vStackView.trailingAnchor.constraint(equalTo: margins.trailingAnchor, constant: 8.0).isActive = true
vStackView.heightAnchor.constraint(equalTo: margins.heightAnchor).isActive = true
}
super.updateConstraints()
}
答案 0 :(得分:1)
您已将按钮放置在<head>
标签内。其他一切都很好。将其放在<body>
内就可以了!
function Crypt() {
var input = document.getElementById('input1').value;
var resultArray = [];
for (var i = 0; i < input.length; i++) {
if (input[i] === 'a') {
resultArray.push('p');
} else if ("input" [i] === 'b') {
resultArray.push('l');
} else if (input[i] === 'c') {
resultArray.push('m');
} else if (input[i] === 'd') {
resultArray.push('n');
} else if (input[i] === 'e') {
resultArray.push('k');
} else if (input[i] === 'f') {
resultArray.push('o');
} else if (input[i] === 'g') {
resultArray.push('i');
} else if (input[i] === 'h') {
resultArray.push('j');
} else if (input[i] === 'i') {
resultArray.push('t');
} else {
resultArray.push(' ');
}
}
document.write(resultArray.join(''));
}
<input type="text" id="input1"/>
<button onclick="Crypt()">Submit</button>