B
B
Bogdan2018-02-20 15:34:05
Vue.js
Bogdan, 2018-02-20 15:34:05

Asynchronous import() components?

Hello. Tell me please. For some reason, when using an asynchronous component connection via import, it gives an error

components: {
    FormInput: () => import('./FormInput')
  }

./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/Checkout.vue
Module build failed: SyntaxError: d:/ProjectRuby/ vue-lavrik/src/components/Checkout.vue: Unexpected token (114:21)
112 | },
113 | components: {
> 114 | FormInput: () => import('./FormInput')
| ^
115 | }
116 | }
117 |

But if you load it classically, then everything works
import FormInput from './FormInput'
....
  components: {
    FormInput:
  }

Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pantagruel964, 2018-02-20
@bogdan_uman

npm i -D babel-plugin-syntax-dynamic-import
.babelrc

{
    "plugins": ["syntax-dynamic-import"]
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question