错误写法1:(没有用require)
this.my_pic = './static/fruit/apple.png';
上面的写法会导致图片无法渲染
错误写法2:(require不支持“纯”变量)
this.my_path = './static/fruit/apple.png';
this.my_pic = require(this.my_path);
上面的写法会报Cannot find module错误。
正确写法:
this.my_file = 'apple.png';
this.my_pic = require('./static/fruit/'+this.my_file);