-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
56 lines (52 loc) · 1.44 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Vue Select2 Component Example</title>
<link href="//cdn.bootcss.com/select2/4.0.3/css/select2.min.css" rel="stylesheet">
</head>
<body>
<div id="app" class="container">
<label>My favorite fruits:</label>
<select2
:options="options"
:model.sync="selectedIdsInArr"
:models.sync="selectedIds"
:config="{ multiple: true, delimiter: '|', showValInText: true }">
</select2>
<hr>
<code>selectedIdsInArr: {{ selectedIdsInArr | json }}</code><br>
<code>selectedIds: {{ selectedIds }}</code>
</div>
<script src="//cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/select2/4.0.3/js/select2.min.js"></script>
<script src="//cdn.bootcss.com/vue/1.0.28/vue.min.js"></script>
<script src="./dist/vue-select2-component.min.js"></script>
<script>
Vue.config.devtools = true;
window.app = new Vue({
el: '#app',
components: {
Select2: VueSelect2
},
data: function () {
return {
options: [
{ value: 1, text: 'Apple' },
{ value: 2, text: 'Banana' },
{ value: 3, text: 'Orange' },
{ value: 4, text: 'Grape' }
],
selectedIdsInArr: [],
selectedIds: ''
};
}
});
// dynamically change values
app.selectedIdsInArr = [1, 2];
setTimeout(function () {
app.selectedIds = '3|4';
}, 2000);
</script>
</body>
</html>