小编tuh*_*n47的帖子

如果我只有一个选项属性,如何在 vue-multiselect 中设置默认值?

我有一个选项数组,它显示在多选选项中。但我需要选择一个提供 id 的默认选项。在我的代码中,我需要选择 id = 2 的默认选项。如何在 vue.js 中使用多选来做到这一点?

<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vue-multiselect@2.1.0"></script>
<link rel="stylesheet" href="https://unpkg.com/vue-multiselect@2.1.0/dist/vue-multiselect.min.css">

<div id="vue-app2">
    <div>
        <label class="typo__label">Single select / dropdown</label>
        <multiselect v-model="value" deselect-label="Can't remove this value" track-by="id" label="name"
            placeholder="Select one" :options="options" :searchable="false" :allow-empty="false">
            <template slot="singleLabel" slot-scope="{ option }"><strong>{{ option.name }}</strong> is written
                in<strong> {{ option.language }}</strong></template>
        </multiselect>
        <pre class="language-json"><code>{{ value  }}</code></pre>
    </div>
</div>
<script >
Vue.component('multiselect', window.VueMultiselect.default);

new Vue({
    el: '#vue-app2',
    data: {
        id:2,
        value:null,
        options: [
            { id:1, name: 'Vue.js', language: 'JavaScript' },
            { id:2, …
Run Code Online (Sandbox Code Playgroud)

multi-select vue.js vue-component

5
推荐指数
1
解决办法
6370
查看次数

Vue 未定义 Bootstrap-vue

我已经在 vue js bootstrap vue 中安装了,使用以下命令\nyarn add bootstrap-vue bootstrap axios

\n

代码:\n图1

\n

在此输入图像描述

\n
    ERROR  Failed to compile with 1 errors                                                                                             2:56:01 AM\n    \n     error  in ./src/main.js\n\nModule Error (from ./node_modules/eslint-loader/index.js):\n\n/home/ronin/Documents/V2/test/src/main.js\n  7:1  error  \'Vue\' is not defined  no-undef\n\n\xe2\x9c\x96 1 problem (1 error, 0 warnings)\n\n\n @ multi (webpack)-dev-server/client?http://192.168.0.161:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js\n
Run Code Online (Sandbox Code Playgroud)\n

ubuntu vue.js bootstrap-vue

5
推荐指数
1
解决办法
5212
查看次数