Home  >  Article  >  Web Front-end  >  Implementation code for using and disabling the vue select component

Implementation code for using and disabling the vue select component

不言
不言Original
2018-04-10 14:52:121682browse

This article mainly introduces the implementation code of using and disabling the vue--select component. Now I share it with everyone. Friends who need it can refer to it

Business: There are two ways to push messages, as " WeChat" and "Mail". When sending via WeChat, you need to select "Application to send". When sending an email, you do not need to select

. When sending via WeChat, the page is as follows:

Implementation code for using and disabling the vue select component

When the email is sent, the selector is not available. The page is as follows:

邮件Implementation code for using and disabling the vue select component

Although no specific example is given on the official website, "disabled" can be found in the attributes. Attribute,


Attribute Description Type Default value
disabled Whether it is disabled Boolean false

Implementation:

Add the disabled attribute and write it in the following red mark format; define an isAble variable to store TRUE and FALSE values ​​to determine whether this selection box is available.

<Select <span style="color: rgb(255, 0, 0);">v-bind:disabled="isAble" </span>clearable v-model="dataAgentEntity.ID" style="width:240px"> 
   <Option v-for="item in dataAgent" :value="item.ID" :key="item.ID">{{ item.name }}</Option> 
 </Select> 

export default { 
  data(){ 
    return{ 
      isAble: false,//select下拉框是否可用 
    } 
  }

Then the value of the operating variable isAble in the logic changes the available disabled state of the component

 methods:{ 
     Test(){ 
      var vm = this; 
       if (vm.alertType == &#39;邮件&#39;) { 
        vm.isAble = true; //不可用 
      } 
        
     }  
}

The test method only states that it is unavailable. When changing back to WeChat, it must become available, otherwise another bug will be buried, haha. But this is business logic. I only introduce the method and take notes. It depends on the situation.

Related recommendations:

vue select second level linkage The second level defaults to the first option value

The above is the detailed content of Implementation code for using and disabling the vue select component. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn