我完全不懂Vue。只是想为Vue添加一个类型自动完成组件。Bootstrap有这样一个组件,但我不知道如何将它们整合起来!
而且,我所能找到的选项要么仅适用于Vue 1.x,要么文档非常糟糕(并且主要将Bootstrap组件移植到Vue 2.x的工作似乎没有包括类型自动完成)。
我完全不懂Vue。只是想为Vue添加一个类型自动完成组件。Bootstrap有这样一个组件,但我不知道如何将它们整合起来!
而且,我所能找到的选项要么仅适用于Vue 1.x,要么文档非常糟糕(并且主要将Bootstrap组件移植到Vue 2.x的工作似乎没有包括类型自动完成)。
我一直使用vue-strap,但它已经很长时间没有维护了...(包括vue 1版本和vue 2的fork)
看看这个(由我自己创建):https://uiv.wxsm.space/typeahead/
(一个简单而优雅的Vue 2和Bootstrap 3实现的typeahead)
安装:
$ npm install uiv --save
示例用法:
<template>
<section>
<label for="input">States of America:</label>
<input id="input" class="form-control" type="text" placeholder="Type to search...">
<typeahead v-model="model" target="#input" :data="states" item-key="name"/>
</section>
</template>
<script>
import {Typeahead} from 'uiv'
import states from '../../assets/data/states.json'
export default {
components: {Typeahead},
data () {
return {
model: '',
states: states.data
}
}
}
</script>
<!-- typeahead-example.vue -->
试试wffranco的vue-strap分支。它旨在支持Vue.js 2.x.x。 我测试了最新的主分支版本(构建2.0.0-pre.11),它可以正常工作:https://jsfiddle.net/LukaszWiktor/kzadgqv9/
<link rel="stylesheet" href="libs/bootstrap/css/bootstrap.css">
<div id="app">
<typeahead v-model="value" v-bind:data="options"></typeahead>
</div>
<script src="libs/vue/vue.js"></script>
<script src="libs/vue-strap/vue-strap.js"></script>
<script>
Vue.component("typeahead", VueStrap.typeahead);
var app = new Vue({
el: "#app",
data: {
value: null,
options: ["foo", "bar", "baz"]
}
})
</script>
officeList = [{name: "abc", color: "red"}, {...snip..}]
- redshift