【问题标题】:vue v-select array of object not showing in select optionvue v-select对象数组未显示在选择选项中
【发布时间】:2021-02-09 18:44:04
【问题描述】:

带有vue的laravel项目。我在应用程序js中安装所有东西以工作v-select,我不知道安装中是否缺少任何东西。如果缺少某些东西,请告诉我v-select标签中有什么问题如果有人遇到过这种情况,请帮忙

在 app.js 上------------------------------- ----------------------


require('./bootstrap');

window.Vue = require('vue');

import VueRouter from 'vue-router'
import Cat from './components/dashboard/category/Category.vue';
import Sub from './components/dashboard/sub-category/sub-category.vue'; 
import Dash from './components/dashboard/Dashboard.vue';
import VueToast from 'vue-toast-notification';
import Vuetify from 'vuetify';
import 'vuetify/dist/vuetify.min.css';
import VModal from 'vue-js-modal';
// import Vue from 'vue';
import vSelect from 'vue-select';
import 'vue-select/dist/vue-select.css';

// Import one of available themes
import 'vue-toast-notification/dist/theme-default.css';
import { Form, HasError, AlertError } from 'vform';

window.Form = Form;


 
// import {routers} from './routers';
Vue.use(Vuetify)
Vue.use(VueToast); 
Vue.use(VueRouter);
Vue.use(VModal);
// Vue.use(vSelect)
Vue.component('v-select', vSelect)
const routes = [
    
    { path: '', component: Dash },
    { path: '/category', component: Cat },
    { path: '/sub-category', component: Sub },
  ]
const router = new VueRouter({
    routes
})

const app = new Vue({
    el: '#app',
    router,
    vuetify: new Vuetify()
});


在组件上--------------------------------- ----------------------------------

 <v-select  v-model="select"  :items="categories" label="Select" item-text="name"  item-value="id" return-object> </v-select>



export default {
  data(){
    return {
        form: new Form({
            name:'',
            imgUrl:'',
            remember: false
      }),
      categories:[],
      select: 'Select',
    }
  },

  mounted(){
   this.getCategories() 
  },
  methods:{
    getCategories(){
      axios.get('sub-category')
      .then(res => (
        res.data.forEach((value, index) => {
            this.categories.push(value);
        })
     ));
    }
  }
}


【问题讨论】:

    标签: laravel vue.js v-select


    【解决方案1】:

    v-select标签中的items属性不应该叫options吗?来源:https://vue-select.org/guide/options.html#options-prop

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-15
      • 2018-08-05
      • 2018-09-05
      • 2021-06-22
      • 2021-02-17
      • 1970-01-01
      • 2021-09-24
      • 1970-01-01
      相关资源
      最近更新 更多