سلام دوستان من یه ماژولی شبیه به این دارم.
const First = ['Do','Create','Play','Go','Stick','Find','Sell','Buy','Gain']
const Second = ['with my friends','laptop','computer','cellphone','mobile','out']
var frand = Math.floor(Math.random()*9)
var lrand = Math.floor(Math.random()*6)
export default class faker{
f = First[frand]
l = Second[lrand]
fill = () => this.f + ' ' + this.l
}
حالا میخوام این ماژول رو در فایل index ایمپورت کنم ، اما مدام ارور زیر رو میگیرم
Uncaught SyntaxError: Cannot use import statement outside a module
فایل index.js هم این شکلیه:
import faker from './faker'
todo = []
let a = document.getElementById('todos')
مشکلش کجاست؟
عبارات import و export بدونه webpack یا ابزاری که این ها رو فعال کنه کار نمیکنه !
شاید پاسخ شما همینجا باشد