我可以检查字符串是否作为接口键存在
interface list {
one: string
two: string
}
const myNumber = "one"
Run Code Online (Sandbox Code Playgroud)
如何检查 myNumber 值是否是接口键
使用 ajv v8.6.3 Nodejs 和 TypeScript
尝试解析 JSON 但我得到了这个Error: strict mode: unknown keyword: "$schema"
有人对此有所了解吗?
export const mySchema ={
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"names": {
"items": {
"type": "number"
},
"type": "array"
}
},
"type": "object"
}
const ajv = new Ajv()
ajv.addMetaSchema(draft7MetaSchema)
ajv.compileParser(mySchema)
Run Code Online (Sandbox Code Playgroud) 使用curl,我尝试对Web 服务功能进行休息调用以创建用户。但是,我不知道所需的参数是什么,也找不到任何相关文档。
我收到错误:
url: mymoodle/webservice/rest/server.php?wstoken=304632866235d8239cd7bf41809dcd03&wsfunction=core_user_create_users&criteria[0][key]=用户名&criteria[0][value]=名称&criteria[1][key]=密码&criteria[1][value]=密码
无效检测到参数值单个结构中缺少必需的键:用户
<style>
#mspop {
display:none;
}
</style>
<div>
<ul>
<li class="check">tem</li>
</ul>
</div>
<div id="mspop" style="background-color:brown;">
<div id="mspopinner"><p id="close">close</p><textarea style="margin: 0px; height: 125px; width: 500px;"></textarea>
<button>submit</button>
</div>
</div>
<script type="text/javascript">
(function() {
var dec_butt = document.getElementsByClassName("check");
dec_butt[0].addEventListener("click",box);
})();
function box(e){
var pop = document.getElementById("mspop");
pop.style.display = "block";
document.addEventListener("click",clik);
}
function clik(){
var pop = document.getElementById("mspop");
if(event.target != pop){
alert("hi");
pop.style.display = "none";
};
};
</script>
Run Code Online (Sandbox Code Playgroud)
第一个自调用函数将"click"事件监听器添加到"li"元素,并使用类"check",在单击时触发box函数.
单击'li'现在激活box函数,box函数将click事件监听器设置为引用clik函数的'document'对象,并将id'mspop'的显示更改为block.
但是,在单击'li'时,clik的addEventlistner赋值也会触发clik,尽管事实上我省略了函数的clik()调用括号.
ajv ×1
curl ×1
interface ×1
javascript ×1
json ×1
moodle ×1
node.js ×1
php ×1
rest ×1
typescript ×1
web-services ×1