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)
Bài liên quan
Up lên nhờ mọi người support
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
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