Javascript 按需呈现预编译的Vue.js组件(网页包2)

Javascript 按需呈现预编译的Vue.js组件(网页包2),javascript,vue.js,vuejs2,vue-loader,Javascript,Vue.js,Vuejs2,Vue Loader,我正在尝试按需渲染vue组件。应用程序由4个部分组成,每个部分只应在调用某些函数(如renderProducts() 我正在使用带有最新vue加载程序的webpack 2(+Vuex,Vuei18n,…) 问题是,这仅在使用独立构建时有效(vue的网页包别名为:vue:'vue/dist/vue.js') 但我认为我可以做得更好,只使用运行时构建(并节省一些KB) 谁都知道,我做错了什么? 这是我的应用程序入口点(仅显示相关部分): 谢谢你的帮助和建议 import './index.scss'

我正在尝试按需渲染vue组件。应用程序由4个部分组成,每个部分只应在调用某些函数(如
renderProducts()

我正在使用带有最新vue加载程序的webpack 2(+Vuex,Vuei18n,…) 问题是,这仅在使用独立构建时有效(vue的网页包别名为:
vue:'vue/dist/vue.js'

但我认为我可以做得更好,只使用运行时构建(并节省一些KB)

谁都知道,我做错了什么? 这是我的应用程序入口点(仅显示相关部分):

谢谢你的帮助和建议

import './index.scss';
import Vue from 'vue';

import MenusComponent from './components/menus/_menus-root.vue';
import CartComponent from './components/cart/_cart-root.vue';
import NavigationComponent from './components/navigation/_navigation-root.vue';
import LocationInfoComponent from './components/location-info/_location-info-root.vue';

...

const menus = new Vue({ name: 'menus-root', render: h => h(MenusComponent), store });
const cart = new Vue({ name: 'cart-root', render: h => h(CartComponent), store });
const navigation = new Vue({ name: 'navigation-root', render: h => h(NavigationComponent), store });
const locationInfo = new Vue({ name: 'location-info-root', render: h => h(LocationInfoComponent), store });

...

window.renderMenus = ({ el }) => {
  menus.$mount(el);
},
window.renderCart = ({ el }) => {
  cart.$mount(el);
},
window.renderNavigation = ({ el }) => {
  navigation.$mount(el);
},
window.renderLocationInfo = ({ el }) => {
  locationInfo.$mount(el);
}