在 extjs 中使用 Ext.get() 获取类

Kis*_*nCS 2 html javascript extjs

你好,我对 ExtJs 很陌生,请帮助我了解 Ext.get()

这有效:

  Ext.get('tag2').hide(); // worked well on with Id
   <div id ="tag2">using id</div><!--given with id-->
Run Code Online (Sandbox Code Playgroud)

现在这就是问题所在

 Ext.get('tag2').hide()//hiding only id not class
 <div class ="tag2">using class</div><!--given with class-->
Run Code Online (Sandbox Code Playgroud)

上课不行。看一下完整的代码:

<!DOCTYPE html>
<html>
   <head>
      <link href="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-neptune/resources/theme-neptune-all.css" rel="stylesheet" />
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/ext-all.js"></script>
      <script type="text/javascript">
         Ext.onReady(function(){
            Ext.get('tag2').hide()//hiding only id not class
            Ext.create('Ext.Button', {
               renderTo: Ext.getElementById('helloWorldPanel'),
               text: 'show',
               listeners: {
                  click: function() {
                     this.hide();
                  },
                  hide: function() {
                     Ext.get('tag1').hide();
                     Ext.get('tag2').show();//not working hear
                  }
               }
            });
         });           
      </script> 
   </head>
   <body>
   <div class ="tag1">Test Div</div>
   <div class ="tag2">using class</div><!--given with class-->
   <div id ="tag2">using id</div><!--given with id-->
   <div id = 'helloWorldPanel' />   <!--  panel will be rendered here-- >
   </body>
</html>
Run Code Online (Sandbox Code Playgroud)

Bar*_*uri 5

使用以下内容代替 get。Get接受 id,查询类时需要使用select

    Ext.select('.tag2').hide();
Run Code Online (Sandbox Code Playgroud)