bootstrap select插件封装成Vue2.0组件
关于如何将Bootstrap Select插件巧妙地封装成Vue 2.0组件的详细指南
在Vue项目中,Bootstrap Select因其强大的功能和优雅的样式而受到广泛欢迎。本文将为您展示如何轻松地将Bootstrap Select插件封装成Vue 2.0组件,以便在项目中使用。
HTML部分
您可以在Vue模板中使用自定义的`
```html
```
JavaScript部分
接下来是Vue组件的定义:
```javascript
Vueponent('vm-select', {
props: ['options', 'value', 'multiple', 'method', 'load', 'index', 'childidx'],
template: `
`,
mounted() {
const 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(vmdex, vm.childidx, this.value);
}
});
$(this.$el).on('show.bs.select', function() {
if (typeof(vm.load) !== 'undefined') {
vm.load(vmdex, vm.childidx);
}
});
},
updated() {
$(this.$el).selectpicker('refresh');
},
destroyed() {
$(this.$el).selectpicker('destroy');
}
});
```
注意事项:当使用多个`
编程语言
- bootstrap select插件封装成Vue2.0组件
- XML CDATA是什么?
- vue2.0在table中实现全选和反选的示例代码
- JavaScript表格常用操作方法汇总
- apache php模块整合操作指南
- 浅析正则表达式
- JS库 Highlightjs 添加代码行号的实现代码
- javascript jquery对form元素的常见操作详解
- ASP检查文件与目录是否存在的函数代码
- 小谈php正则提取图片地址
- javascript之Array 数组对象详解
- 如何制作一个防止多次刷新计数的图片计数器?
- asp下利用xml打包网站文件
- Angular中$cacheFactory的作用和用法实例详解
- fsockopen pfsockopen函数被禁用,SMTP发送邮件不正常
- 表单正则验证及文件上传验证功能