Хм, я думаю, вы не поняли, что добавляете Vue как node
к div#mainForm
.
Как узел, узел выбора не входит в область вашего SPA. И более того - я не совсем уверен - но я думаю, что в процессе монтажа все остальные узлы удаляются из div#mainForm
Это больше похоже на то, что вы хотите:
import Vue from "vue";
Vue.config.productionTip = false;
Vue.component("product-type-component", {
data() {
return { listProductType: [] };
},
beforeMount() {
// axios.get('http://localhost/admin/getListProductType')
// .then(response => {
// this.listProductType = response.data
// })
},
template: "<option " + /* v-for... */ ">some option</option>"
});
new Vue({
el: "#app",
template: `<select><product-type-component></product-type-component></select>`
});
рабочий образец: песочница
import Vue from "vue";
import { METHODS } from "http";
import * as axios from "axios";
Vue.config.productionTip = false;
var productTypeComponent = Vue.component("product-type-component", {
data() {
return { listProductType: [] };
},
beforeMount() {
axios.get("https://dog.ceo/api/breeds/list/all").then(response => {
console.log(response);
this.listProductType = Object.keys(response.data.message);
});
console.log("///" + this.listProductType);
},
template:
'<select><option v-for="(item, index) in listProductType" v-bind:value="item">{{item}}</option></select>'
});
var vm = new Vue({
el: "#app",
data: {},
methods: {},
template: `<div><product-type-component /></div>`
});