鍍金池/ 問答/HTML/ vue-cli使用webpack動態(tài)注冊組件后無法使用slot無法實(shí)現(xiàn)內(nèi)容分發(fā)

vue-cli使用webpack動態(tài)注冊組件后無法使用slot無法實(shí)現(xiàn)內(nèi)容分發(fā)

  • 使用webpack動態(tài)注冊組件后無法使用slot無法實(shí)現(xiàn)內(nèi)容分發(fā)
  • 單獨(dú)的注冊組件是沒有問題的,問題不知道出在哪里
  • 以下為webpack動態(tài)注冊組件代碼
import Vue from "vue";

function capitalizeFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}

const requireComponent = require.context(
    ".",
    true,
    /\.vue$/
);

requireComponent.keys().forEach(fileName => {
    console.log(`${fileName.substring(fileName.lastIndexOf("/")  + 1).replace(/\.\w+$/, "")}      路徑:'${fileName}'`);
    const componentConfig = requireComponent(fileName);
    const componentName = capitalizeFirstLetter(
        fileName.substring(fileName.lastIndexOf("/")  + 1).replace(/\.\w+$/, "")
    );
    Vue.component(componentName, componentConfig.default || componentConfig);
});
回答
編輯回答
瘋浪

已解決,非webpack的問題

2017年4月11日 14:54