Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to encapsulate select plug-in into Vue2.0 component in bootstrap

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

In this article Xiaobian introduces in detail "how the select plug-in in bootstrap is encapsulated into Vue2.0 components", the content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how the select plug-in in bootstrap is encapsulated into Vue2.0 components" can help you solve your doubts.

Html

Js

/ / select plug-in Vue.component ('vm-select', {props: [' options', 'value',' multiple', 'method',' load', 'index',' childidx'], template: "{{option.label}}", mounted: function () {var vm = this; $(this.$el) .selectpicker ('val', this.value! = null? This.value: null); $(this.$el) .on ('changed.bs.select', function () {vm.$emit (' input', $(this). Val ()); if (typeof (vm.method)! = 'undefined') {vm.method (vm.index, vm.childidx, this.value);}}) (this.$el) .on ('show.bs.select', function () {if (typeof (vm.load)! =' undefined') {vm.load (vm.index, vm.childidx);}});}, updated: function () {$(this.$el) .selectpicker ('refresh');}, destroyed: function () {$(this.$el) .selectpicker (' destroy');}})

I have to mention that when using multiple select, when deleting a selcet object, the loaded value will change. After a long time, it is found that it is the problem of vue itself: because the vue object will reuse the same vue object in the process of re-rendering the html, it will lead to the dislocation of the selcet object. Solution: label each select object key. Although it may lead to performance degradation, it does not cause errors.

After reading this, the article "how to package select plug-ins in bootstrap into Vue2.0 components" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it to understand it. If you want to know more about related articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report