账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    vue 异步组件 components 如何用函数引入
    53
    0
    想把 components 独立出来,写成这样一份 jscomponents.jsconst COMPONENTS = {LocationList: () => import('../components/LocationList'),StationList: () => import('../components/StationList'),DeviceSelectList: () => import('../components/DeviceSelectList'),}export default COMPONENTSindex.vueimport COMPONENTS from './components.js'export default {components: COMPONENTS}这样是可以用的但是我改成函数的形式就报错了// 所有的组件+ const componentCreator = (path) => {+ return () => import(path)+ }+ const LocationList = componentCreator('../components/LocationList')+ console.log('LocationList', LocationList)const COMPONENTS = {- LocationList: () => import('../components/LocationList'),+ LocationList, StationList: () => import('../components/StationList'), DeviceSelectList: () => import('../components/DeviceSelectList'),}export default COMPONENTS这样就渲染不出来对应的组件 vue 发出警告vue.runtime.esm.js?2b0e:619 [Vue warn]: Failed to resolve async component: function () { return Promise.resolve("".concat(path)).then(function (s) { return Object(_Users_ishowYoung_Project_shuyi_front_end_node_modules_babel_runtime_helpers_esm_interopRequireWildcard__WEBPACK_IMPORTED_MODULE_1__["default"])(__webpack_require__("./src/components/common-email/src sync recursive")(s)); }); }Reason: Error: Cannot find module '../components/LocationList'
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 一只鹿ii 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部