在json文件中搜索关键角度2+

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在json文件中搜索关键角度2+相关的知识,希望对你有一定的参考价值。

在我的网站上,我想验证用户在输入3个字母代码或2个字母代码时所做的输入。它应该返回键的值。因此,如果他键入“BTC”,它应该返回“比特币”并在输入旁边显示它。我找到了这个例子,但对我想要的东西来说似乎很复杂:https://github.com/ghiden/angucomplete-alt,它是angularjs

      Search three lettercode coin: <input ng-model="query">
        
      

{

  "42": "42 Coin",

  "365": "365Coin",

  "404": "404Coin",

  "611": "SixEleven",

  "808": "808"
  
  }
答案

最简单的方法是: - 检查每种类型的表单输入

oninput="checkInput($event)"

然后你可以看到它是否匹配任何键:

function outputData(value) {
    alert(value);
}

function checkInput(event) {
    // Check event.target.value with either if cases or a switch statement and 
    //then trigger the function that outputs the key value.
    if (event.target.value === 'BTC') {
        outputData('Bitcon');
    } else if (event.target.value === '....') {
        .....
    }
}

以上是关于在json文件中搜索关键角度2+的主要内容,如果未能解决你的问题,请参考以下文章

这些角度电子邮件指令代码片段如何连接

VS Code配置snippets代码片段快速生成html模板,提高前端编写效率

前端开发工具vscode如何快速生成代码片段

VSCode 如何操作用户自定义代码片段(快捷键)

在一个活动中加载单个片段两次,从本地json文件中加载2个问题

从JVM的角度看JAVA代码--代码优化