01/10/2018, 17:40

Cách khai báo const bien = () => import('path') trong javascript ý nghĩa thế nào?

Chào mọi người,
Mình tính tự gắn cái https://github.com/coreui/coreui-free-vue-admin-template vào laravel 5.7 (hoặc 5.6)
Nhưng khi chạy lệnh npm run dev, nó chạy tới

E:/xampp/htdocs/laravel56/resources/assets/js/admin/router/index.js 

Thì báo lỗi ở dòng code:

const DefaultContainer = () => import('@/containers/DefaultContainer')

Bạn nảo rành jaravscript cho hỏi lỗi bên dưới là gì và cách giải quyết với ạ

ERROR in ./resources/assets/js/admin/router/index.js
Module build failed: SyntaxError: E:/xampp/htdocs/laravel56/resources/assets/js/admin/router/index.js: Unexpected token (5:31)
Hoang Trang viết 19:56 ngày 01/10/2018

Up lên nhờ mọi người support

*grab popcorn* viết 19:54 ngày 01/10/2018

Cái đó ở JS là dynamic import.
VueJS là async component.

Bạn thử config babel hoặc webpack mà laravel xài để có thể build được cú pháp này. Mình thì ko biết laravel nên tìm ra mỗi link này:

github.com/JeffreyWay/laravel-mix

Issue: Vue.js Async Components

opened by pix2D on 2017-10-08
Laravel Mix Version: 1.4.5
Node Version (node -v): 8.5.0
NPM Version (npm -v): 5.4.2
OS: macOS High Sierra
Description:
Does anyone know how to get Vue.js...

Hoang Trang viết 19:55 ngày 01/10/2018

Cảm ơn bạn, mình đã chạy được sau khi cài dynamic import tại https://github.com/airbnb/babel-plugin-dynamic-import-node

Bài liên quan
0