欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

bootstrap中select插件如何封裝成Vue2.0組件

這篇文章主要介紹bootstrap中select插件如何封裝成Vue2.0組件,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!

創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),掇刀企業(yè)網(wǎng)站建設(shè),掇刀品牌網(wǎng)站建設(shè),網(wǎng)站定制,掇刀網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,掇刀網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競爭力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。

因為bootstrap-select功能比較強(qiáng)大,而且樣式還不錯,所以在項目使用了vue,所以,覺得對bootstrap-select進(jìn)行封裝。

html

<my-select :options="input.options" v-model="input.value" ref="typeSelect" :index="index" :childidx="childIdx" :load="load" :multiple="input.multiple" :method="change"></my-select>

js

// select 插件
Vue.component('vm-select', {
 props : ['options', 'value', 'multiple', 'method', 'load', 'index', 'childidx'],
 template : "<select :multiple='multiple' class='selectpicker' data-live-search='true' title='請選擇' data-live-search-placeholder='搜索'><option :value='option.value' v-for='option in options'>{{ option.label }}</option></select>",
 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');
 }
});

不得不提一下,在使用多個select的時候,在刪除某一個selcet對象的時候,加載的值會發(fā)生改變,糾結(jié)了半天發(fā)現(xiàn)是vue自身的問題:因為vue對象有在重新渲染html的過程中會復(fù)用原來相同的vue對象,所以導(dǎo)致會導(dǎo)致selcet對象錯位。解決方案:將每個select對象打上一個標(biāo)簽key。雖然可能導(dǎo)致性能的下降,但是不會導(dǎo)致錯誤。

bootstrap中select插件如何封裝成Vue2.0組件

以上是“bootstrap中select插件如何封裝成Vue2.0組件”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

網(wǎng)站欄目:bootstrap中select插件如何封裝成Vue2.0組件
本文URL:http://www.chinadenli.net/article48/peiehp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司ChatGPT云服務(wù)器App開發(fā)營銷型網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)