0

带有 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);
        })
     ));
    }
  }
}


4

1 回答 1

0

不应该调用标签中的items属性吗?来源:https ://vue-select.org/guide/options.html#options-propv-selectoptions

于 2020-10-27T17:35:41.250 回答